{
  "openapi": "3.1.0",
  "info": {
    "title": "OpenGunstore API",
    "version": "1.8.1",
    "description": "RPC API of the OpenGunstore custom apps (Frappe/ERPNext v16): ffl_core, ffl_integrations, ffl_woo_sync.\n\nAll endpoints are Frappe *whitelisted methods* invoked as `/api/method/<dotted.path>`. Unless an endpoint declares explicit HTTP verbs, it is documented here as POST (Frappe also accepts GET for read-only calls; always POST mutations). Arguments may be sent as JSON body, form data, or query string — JSON body is recommended.\n\nEvery operation carries an **Auth (derived from code)** line statically resolved from the role gate the function actually executes; the prose Permissions note adds semantics the machine can't infer.\n\nStandard CRUD on DocTypes is served by Frappe's REST layer (`/api/resource/<DocType>`) — see docs/api/frappe-rest.md; the custom DocTypes are modelled under components.schemas and listed in reference/doctypes.md."
  },
  "servers": [
    {
      "url": "http://dev.localhost:8000",
      "description": "local dev bench (safe default)"
    },
    {
      "url": "https://pos.example.com",
      "description": "PRODUCTION external API entry (pos.example.com /api/* → the live POS) — live store and bound-book data; call only with authorized credentials"
    }
  ],
  "tags": [
    {
      "name": "ffl_core",
      "description": "FFL retail core: A&D book, 4473, intake, consignment, POS session"
    },
    {
      "name": "ffl_integrations",
      "description": "FastBound, Payroc, RSR/distributors, ShipStation, ATF EZ-Check"
    },
    {
      "name": "ffl_woo_sync",
      "description": "WooCommerce product/stock/order sync"
    },
    {
      "name": "webhooks",
      "description": "Inbound webhooks (guest-accessible, signature-verified)"
    }
  ],
  "security": [
    {
      "tokenAuth": []
    }
  ],
  "components": {
    "securitySchemes": {
      "tokenAuth": {
        "type": "apiKey",
        "in": "header",
        "name": "Authorization",
        "description": "`Authorization: token <api_key>:<api_secret>` — per-user keys, see docs/api/README.md"
      }
    },
    "responses": {
      "FrappeError": {
        "description": "Frappe error envelope. HTTP 4xx/5xx with JSON body: `exc_type`, `exception`, `_server_messages` (JSON-encoded list of user-facing messages)."
      }
    },
    "schemas": {
      "ATF_FFL_Record": {
        "type": "object",
        "description": "Custom DocType (ffl_core); CRUD via /api/resource/ATF%20FFL%20Record — see docs/api/frappe-rest.md.",
        "properties": {
          "ffl_number": {
            "type": "string",
            "description": "FFL Number"
          },
          "license_type": {
            "type": "string",
            "description": "License Type"
          },
          "licensee_name": {
            "type": "string",
            "description": "Licensee Name"
          },
          "licensee_dba": {
            "type": "string",
            "description": "Doing Business As"
          },
          "phone": {
            "type": "string",
            "description": "Phone"
          },
          "expiry_date": {
            "type": "string",
            "description": "Expiry Date"
          },
          "cfd_number": {
            "type": "string",
            "description": "CFD Number"
          },
          "street": {
            "type": "string",
            "description": "Street"
          },
          "street2": {
            "type": "string",
            "description": "Street Address 2"
          },
          "city": {
            "type": "string",
            "description": "City"
          },
          "state": {
            "type": "string",
            "description": "State"
          },
          "zip": {
            "type": "string",
            "description": "ZIP"
          },
          "loaded_from": {
            "type": "string",
            "description": "Loaded From"
          },
          "loaded_at": {
            "type": "string",
            "description": "Loaded At"
          },
          "live_verified_at": {
            "type": "string",
            "description": "Live-Verified At"
          }
        },
        "required": [
          "ffl_number"
        ]
      },
      "Agreement_Template": {
        "type": "object",
        "description": "Custom DocType (ffl_core); CRUD via /api/resource/Agreement%20Template — see docs/api/frappe-rest.md.",
        "properties": {
          "title": {
            "type": "string",
            "description": "Title"
          },
          "scope": {
            "type": "string",
            "enum": [
              "Per customer",
              "Each firearm sold",
              "Per document"
            ],
            "description": "Signed"
          },
          "valid_days": {
            "type": "integer",
            "description": "Valid For (Days)"
          },
          "one_copy_per_gun": {
            "type": "integer",
            "enum": [
              0,
              1
            ],
            "description": "One copy per gun"
          },
          "active": {
            "type": "integer",
            "enum": [
              0,
              1
            ],
            "description": "Active"
          },
          "version": {
            "type": "integer",
            "description": "Version"
          },
          "requirement": {
            "type": "string",
            "enum": [
              "Optional",
              "Required by item",
              "Required for every sale"
            ],
            "description": "Required"
          },
          "show_on_counter_panel": {
            "type": "integer",
            "enum": [
              0,
              1
            ],
            "description": "Show on Counter Panel"
          },
          "minors_need_guardian": {
            "type": "integer",
            "enum": [
              0,
              1
            ],
            "description": "Minors Need a Parent or Guardian"
          },
          "body": {
            "type": "string",
            "description": "Agreement Text"
          },
          "description": {
            "type": "string",
            "description": "Staff Notes"
          }
        },
        "required": [
          "title",
          "body"
        ]
      },
      "CRM_Customer_Memory": {
        "type": "object",
        "description": "Custom DocType (ffl_core); CRUD via /api/resource/CRM%20Customer%20Memory — see docs/api/frappe-rest.md.",
        "properties": {
          "customer": {
            "type": "string",
            "description": "Customer (Link: Customer)"
          },
          "contact": {
            "type": "string",
            "description": "Contact (Link: Contact)"
          },
          "lead": {
            "type": "string",
            "description": "Lead (Link: CRM Lead)"
          },
          "auto_update": {
            "type": "integer",
            "enum": [
              0,
              1
            ],
            "description": "Update with AI"
          },
          "items": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/CRM_Customer_Memory_Item"
            },
            "description": "Items"
          }
        }
      },
      "CRM_Customer_Memory_Item": {
        "type": "object",
        "description": "Custom DocType (ffl_core); CRUD via /api/resource/CRM%20Customer%20Memory%20Item — see docs/api/frappe-rest.md.",
        "properties": {
          "kind": {
            "type": "string",
            "enum": [
              "want",
              "budget",
              "state",
              "trade_in",
              "preference",
              "question"
            ],
            "description": "Kind"
          },
          "text": {
            "type": "string",
            "description": "Text"
          },
          "keywords": {
            "type": "string",
            "description": "Keywords"
          },
          "amount": {
            "type": "number",
            "description": "Amount"
          },
          "said": {
            "type": "string",
            "enum": [
              "Customer",
              "Staff",
              "Order"
            ],
            "description": "Said by"
          },
          "source_doctype": {
            "type": "string",
            "description": "Source type (Link: DocType)"
          },
          "source_name": {
            "type": "string",
            "description": "Source (Link: source_doctype)"
          },
          "noted_on": {
            "type": "string",
            "description": "Noted on"
          },
          "locked": {
            "type": "integer",
            "enum": [
              0,
              1
            ],
            "description": "Locked"
          }
        },
        "required": [
          "kind"
        ]
      },
      "CRM_Deal_Hold": {
        "type": "object",
        "description": "Custom DocType (ffl_core); CRUD via /api/resource/CRM%20Deal%20Hold — see docs/api/frappe-rest.md.",
        "properties": {
          "serial_no": {
            "type": "string",
            "description": "Serial No (Link: Serial No)"
          },
          "item_code": {
            "type": "string",
            "description": "Item (Link: Item)"
          },
          "deal": {
            "type": "string",
            "description": "Deal"
          },
          "status": {
            "type": "string",
            "enum": [
              "Active",
              "Released",
              "Expired"
            ],
            "description": "Status"
          },
          "held_by": {
            "type": "string",
            "description": "Held by (Link: User)"
          },
          "held_at": {
            "type": "string",
            "description": "Held at"
          },
          "expires_at": {
            "type": "string",
            "description": "Held until"
          },
          "extensions": {
            "type": "integer",
            "description": "Extensions"
          },
          "ended_at": {
            "type": "string",
            "description": "Ended at"
          },
          "ended_by": {
            "type": "string",
            "description": "Ended by (Link: User)"
          },
          "end_reason": {
            "type": "string",
            "enum": [
              "Released",
              "Expired",
              "Deal won",
              "Deal lost",
              "Deal deleted",
              "Off the deal",
              "Sold to the customer",
              "Manager override",
              "Gun left stock",
              "Taken by another order"
            ],
            "description": "Why it ended"
          },
          "approved_by": {
            "type": "string",
            "description": "Approved by (Link: User)"
          },
          "note": {
            "type": "string",
            "description": "Note"
          },
          "active_serial": {
            "type": "string",
            "description": "Active serial"
          }
        },
        "required": [
          "serial_no",
          "item_code",
          "deal",
          "status",
          "expires_at"
        ]
      },
      "CRM_Mail_Category": {
        "type": "object",
        "description": "Custom DocType (ffl_core); CRUD via /api/resource/CRM%20Mail%20Category — see docs/api/frappe-rest.md.",
        "properties": {
          "category_name": {
            "type": "string",
            "description": "Category"
          }
        },
        "required": [
          "category_name"
        ]
      },
      "CRM_Mail_Category_Rule": {
        "type": "object",
        "description": "Custom DocType (ffl_core); CRUD via /api/resource/CRM%20Mail%20Category%20Rule — see docs/api/frappe-rest.md.",
        "properties": {
          "domain": {
            "type": "string",
            "description": "Domain"
          },
          "category": {
            "type": "string",
            "description": "Category (Link: CRM Mail Category)"
          }
        },
        "required": [
          "domain",
          "category"
        ]
      },
      "CRM_Want": {
        "type": "object",
        "description": "Custom DocType (ffl_core); CRUD via /api/resource/CRM%20Want — see docs/api/frappe-rest.md.",
        "properties": {
          "contact": {
            "type": "string",
            "description": "Contact (Link: Contact)"
          },
          "customer": {
            "type": "string",
            "description": "Customer (Link: Customer)"
          },
          "deal": {
            "type": "string",
            "description": "Deal (Link: CRM Deal)"
          },
          "status": {
            "type": "string",
            "enum": [
              "Open",
              "Matched",
              "Closed"
            ],
            "description": "Status"
          },
          "want_owner": {
            "type": "string",
            "description": "Owner (Link: User)"
          },
          "keywords": {
            "type": "string",
            "description": "Keywords"
          },
          "item": {
            "type": "string",
            "description": "Item (Link: Item)"
          },
          "budget": {
            "type": "number",
            "description": "Budget"
          },
          "notes": {
            "type": "string",
            "description": "Notes"
          },
          "source_doctype": {
            "type": "string",
            "description": "Source type (Link: DocType)"
          },
          "source_name": {
            "type": "string",
            "description": "Customer message (Link: source_doctype)"
          },
          "memory_row": {
            "type": "string",
            "description": "Memory row"
          },
          "memory_synced": {
            "type": "string",
            "description": "Memory synced"
          },
          "matched_item": {
            "type": "string",
            "description": "Matched item (Link: Item)"
          },
          "matched_serial": {
            "type": "string",
            "description": "Matched serial"
          },
          "matched_on": {
            "type": "string",
            "description": "Matched on"
          },
          "arrival_task": {
            "type": "string",
            "description": "Arrival task"
          }
        },
        "required": [
          "contact",
          "status"
        ]
      },
      "Caliber": {
        "type": "object",
        "description": "Custom DocType (ffl_core); CRUD via /api/resource/Caliber — see docs/api/frappe-rest.md.",
        "properties": {
          "caliber_name": {
            "type": "string",
            "description": "Caliber Name"
          },
          "abbreviation": {
            "type": "string",
            "description": "Abbreviation"
          },
          "metric_equivalent": {
            "type": "string",
            "description": "Metric / Equivalent"
          },
          "category": {
            "type": "string",
            "enum": [
              "Pistol",
              "Rifle",
              "Shotgun",
              "Rimfire",
              "Magnum",
              "Other"
            ],
            "description": "Category"
          }
        },
        "required": [
          "caliber_name"
        ]
      },
      "Cash_Drawer_Close": {
        "type": "object",
        "description": "Custom DocType (ffl_core); CRUD via /api/resource/Cash%20Drawer%20Close — see docs/api/frappe-rest.md.",
        "properties": {
          "company": {
            "type": "string",
            "description": "Company (Link: Company)"
          },
          "business_date": {
            "type": "string",
            "description": "Day"
          },
          "status": {
            "type": "string",
            "enum": [
              "Closed",
              "Closing",
              "Undone"
            ],
            "description": "Status"
          },
          "is_counted": {
            "type": "integer",
            "enum": [
              0,
              1
            ],
            "description": "Counted"
          },
          "is_cutoff": {
            "type": "integer",
            "enum": [
              0,
              1
            ],
            "description": "First count"
          },
          "opening_amount": {
            "type": "number",
            "description": "Opening"
          },
          "expected": {
            "type": "number",
            "description": "Expected"
          },
          "counted": {
            "type": "number",
            "description": "Counted"
          },
          "variance": {
            "type": "number",
            "description": "Difference"
          },
          "carry_forward": {
            "type": "number",
            "description": "Carried to the next day"
          },
          "reason": {
            "type": "string",
            "description": "Reason"
          },
          "counted_by": {
            "type": "string",
            "description": "Counted by (Link: User)"
          },
          "counted_at": {
            "type": "string",
            "description": "Counted at"
          },
          "closed_at": {
            "type": "string",
            "description": "Closed at"
          },
          "days_covered": {
            "type": "integer",
            "description": "Days covered"
          },
          "covers_from": {
            "type": "string",
            "description": "Covers days not counted since"
          },
          "variance_je": {
            "type": "string",
            "description": "Difference entry (Link: Journal Entry)"
          },
          "cutoff_je": {
            "type": "string",
            "description": "First count entry (Link: Journal Entry)"
          },
          "trueup_je": {
            "type": "string",
            "description": "Earlier days corrected entry (Link: Journal Entry)"
          },
          "pos_closing_entries": {
            "type": "string",
            "description": "POS closings"
          },
          "active_key": {
            "type": "string",
            "description": "Active key"
          }
        },
        "required": [
          "company",
          "business_date"
        ]
      },
      "Cash_Drawer_Entry": {
        "type": "object",
        "description": "Custom DocType (ffl_core); CRUD via /api/resource/Cash%20Drawer%20Entry — see docs/api/frappe-rest.md.",
        "properties": {
          "company": {
            "type": "string",
            "description": "Company (Link: Company)"
          },
          "entry_type": {
            "type": "string",
            "enum": [
              "Deposit",
              "From Bank",
              "Expense",
              "Payout",
              "Payout Adjustment",
              "Trade-in Payout",
              "Goods Payout",
              "Owner Draw"
            ],
            "description": "What for"
          },
          "status": {
            "type": "string",
            "enum": [
              "Posted",
              "Voided"
            ],
            "description": "Status"
          },
          "posting_date": {
            "type": "string",
            "description": "Date"
          },
          "amount": {
            "type": "number",
            "description": "Amount"
          },
          "payment_method": {
            "type": "string",
            "enum": [
              "Cash",
              "Zelle",
              "Check",
              "ACH"
            ],
            "description": "Paid by"
          },
          "reference": {
            "type": "string",
            "description": "Bank reference"
          },
          "withdrawer": {
            "type": "string",
            "description": "Taken by"
          },
          "expense_account": {
            "type": "string",
            "description": "Expense account (Link: Account)"
          },
          "memo": {
            "type": "string",
            "description": "Memo"
          },
          "receipt": {
            "type": "string",
            "description": "Receipt"
          },
          "acquisition": {
            "type": "string",
            "description": "Acquisition (Link: FFL Acquisition)"
          },
          "serial": {
            "type": "string",
            "description": "Serial number"
          },
          "invoice": {
            "type": "string",
            "description": "Invoice (Link: POS Invoice)"
          },
          "customer": {
            "type": "string",
            "description": "Customer (Link: Customer)"
          },
          "purchase_receipt": {
            "type": "string",
            "description": "Purchase Receipt (Link: Purchase Receipt)"
          },
          "debit_account": {
            "type": "string",
            "description": "Debit account (Link: Account)"
          },
          "credit_account": {
            "type": "string",
            "description": "Credit account (Link: Account)"
          },
          "journal_entry": {
            "type": "string",
            "description": "Journal Entry (Link: Journal Entry)"
          },
          "payout_key": {
            "type": "string",
            "description": "Payout key"
          },
          "voided_by": {
            "type": "string",
            "description": "Undone by (Link: User)"
          },
          "voided_on": {
            "type": "string",
            "description": "Undone on"
          },
          "net_before_undo": {
            "type": "number",
            "description": "Net before undo"
          }
        },
        "required": [
          "company",
          "entry_type",
          "amount"
        ]
      },
      "Cash_Drawer_Expense_Account": {
        "type": "object",
        "description": "Custom DocType (ffl_core); CRUD via /api/resource/Cash%20Drawer%20Expense%20Account — see docs/api/frappe-rest.md.",
        "properties": {
          "account": {
            "type": "string",
            "description": "Account (Link: Account)"
          }
        },
        "required": [
          "account"
        ]
      },
      "Cash_Drawer_Settings": {
        "type": "object",
        "description": "Custom DocType (ffl_core); CRUD via /api/resource/Cash%20Drawer%20Settings — see docs/api/frappe-rest.md.",
        "properties": {
          "variance_threshold": {
            "type": "number",
            "description": "Count difference that needs a reason"
          },
          "expense_cap": {
            "type": "number",
            "description": "Biggest cash expense"
          },
          "expense_accounts": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Cash_Drawer_Expense_Account"
            },
            "description": "Accounts a cash expense can go to"
          },
          "tracking_started": {
            "type": "string",
            "description": "Cash tracking started"
          }
        }
      },
      "Catalog_Category": {
        "type": "object",
        "description": "Custom DocType (ffl_core); CRUD via /api/resource/Catalog%20Category — see docs/api/frappe-rest.md.",
        "properties": {
          "slug": {
            "type": "string",
            "description": "Slug"
          },
          "node_name": {
            "type": "string",
            "description": "Name"
          },
          "path": {
            "type": "string",
            "description": "Path"
          },
          "parent_slug": {
            "type": "string",
            "description": "Parent (Link: Catalog Category)"
          },
          "active": {
            "type": "integer",
            "enum": [
              0,
              1
            ],
            "description": "Active"
          },
          "menu": {
            "type": "integer",
            "enum": [
              0,
              1
            ],
            "description": "In store menu"
          },
          "store_hint": {
            "type": "string",
            "description": "Store category slug (first link)"
          },
          "item_group": {
            "type": "string",
            "description": "Item Group (Link: Item Group)"
          },
          "group_parent": {
            "type": "string",
            "description": "Group aligned under"
          },
          "woo_term_retail": {
            "type": "integer",
            "description": "Retail store category id"
          },
          "level": {
            "type": "integer",
            "description": "Level"
          },
          "position": {
            "type": "integer",
            "description": "Position"
          },
          "seq": {
            "type": "integer",
            "description": "Tree sequence"
          }
        },
        "required": [
          "slug"
        ]
      },
      "Connector_Audit_Log": {
        "type": "object",
        "description": "Custom DocType (ffl_core); CRUD via /api/resource/Connector%20Audit%20Log — see docs/api/frappe-rest.md.",
        "properties": {
          "started_at": {
            "type": "string",
            "description": "Started At"
          },
          "user": {
            "type": "string",
            "description": "User"
          },
          "full_name": {
            "type": "string",
            "description": "Full Name"
          },
          "tool": {
            "type": "string",
            "description": "Tool"
          },
          "status": {
            "type": "string",
            "enum": [
              "Started",
              "Success",
              "Failed"
            ],
            "description": "Status"
          },
          "surface": {
            "type": "string",
            "enum": [
              "cpa",
              "full",
              "web_ro"
            ],
            "description": "Surface"
          },
          "client_name": {
            "type": "string",
            "description": "Connector"
          },
          "client_id": {
            "type": "string",
            "description": "OAuth Client"
          },
          "finished_at": {
            "type": "string",
            "description": "Finished At"
          },
          "arguments": {
            "type": "string",
            "description": "Arguments"
          },
          "error": {
            "type": "string",
            "description": "Error"
          }
        }
      },
      "Create_Order_Draft": {
        "type": "object",
        "description": "Custom DocType (ffl_core); CRUD via /api/resource/Create%20Order%20Draft — see docs/api/frappe-rest.md.",
        "properties": {
          "title": {
            "type": "string",
            "description": "Title"
          },
          "customer": {
            "type": "string",
            "description": "Customer"
          },
          "total": {
            "type": "number",
            "description": "Items Total"
          },
          "payload": {
            "type": "string",
            "description": "Payload (JSON)"
          }
        }
      },
      "Customer_Agreement": {
        "type": "object",
        "description": "Custom DocType (ffl_core); CRUD via /api/resource/Customer%20Agreement — see docs/api/frappe-rest.md.",
        "properties": {
          "customer": {
            "type": "string",
            "description": "Customer (Link: Customer)"
          },
          "customer_name": {
            "type": "string",
            "description": "Customer Name"
          },
          "status": {
            "type": "string",
            "enum": [
              "Pending",
              "Signed",
              "Void",
              "Expired"
            ],
            "description": "Status"
          },
          "expires_on": {
            "type": "string",
            "description": "Expires On"
          },
          "template": {
            "type": "string",
            "description": "Agreement (Link: Agreement Template)"
          },
          "template_version": {
            "type": "integer",
            "description": "Agreement Version"
          },
          "serial_no": {
            "type": "string",
            "description": "Firearm (Serial No) (Link: Serial No)"
          },
          "item_code": {
            "type": "string",
            "description": "Item (Link: Item)"
          },
          "company": {
            "type": "string",
            "description": "Company (Link: Company)"
          },
          "firearms": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Customer_Agreement_Firearm"
            },
            "description": "Firearms"
          },
          "signed_on": {
            "type": "string",
            "description": "Signed On"
          },
          "signed_via": {
            "type": "string",
            "enum": [
              "Tablet",
              "Remote",
              "Paper"
            ],
            "description": "Signed Via"
          },
          "signer_name": {
            "type": "string",
            "description": "Signed By"
          },
          "signer_relationship": {
            "type": "string",
            "enum": [
              "Self",
              "Parent",
              "Guardian"
            ],
            "description": "Signer Is"
          },
          "signature": {
            "type": "string",
            "description": "Signature"
          },
          "signed_pdf": {
            "type": "string",
            "description": "Signed Copy (PDF)"
          },
          "paper_signed_on": {
            "type": "string",
            "description": "Date on Paper"
          },
          "recorded_by": {
            "type": "string",
            "description": "Paper Copy Recorded By (Link: User)"
          },
          "participant_is_minor": {
            "type": "integer",
            "enum": [
              0,
              1
            ],
            "description": "Participant Under 18"
          },
          "minor_determined_by": {
            "type": "string",
            "enum": [
              "Date of Birth",
              "Self-declared",
              "Paper"
            ],
            "description": "Age Taken From"
          },
          "requested_by": {
            "type": "string",
            "description": "Requested By (Link: User)"
          },
          "delivery_channel": {
            "type": "string",
            "enum": [
              "QR",
              "Email",
              "Terminal"
            ],
            "description": "Sent As"
          },
          "token_expires": {
            "type": "string",
            "description": "Link Expires"
          },
          "sign_token_hash": {
            "type": "string",
            "description": "Sign Token Hash"
          },
          "void_reason": {
            "type": "string",
            "description": "Void Reason"
          },
          "reference_doctype": {
            "type": "string",
            "description": "Reference Type (Link: DocType)"
          },
          "reference_name": {
            "type": "string",
            "description": "Reference (Link: reference_doctype)"
          },
          "signing_terminal": {
            "type": "string",
            "description": "Signing Terminal (Link: Signing Terminal)"
          },
          "signer_ip": {
            "type": "string",
            "description": "Signer IP"
          },
          "signer_user_agent": {
            "type": "string",
            "description": "Signer Device"
          },
          "body_snapshot": {
            "type": "string",
            "description": "Text"
          }
        },
        "required": [
          "customer",
          "template"
        ]
      },
      "Customer_Agreement_Firearm": {
        "type": "object",
        "description": "Custom DocType (ffl_core); CRUD via /api/resource/Customer%20Agreement%20Firearm — see docs/api/frappe-rest.md.",
        "properties": {
          "serial_no": {
            "type": "string",
            "description": "Serial No (Link: Serial No)"
          },
          "item_code": {
            "type": "string",
            "description": "Item (Link: Item)"
          },
          "price": {
            "type": "number",
            "description": "Price"
          }
        },
        "required": [
          "serial_no"
        ]
      },
      "Customer_Alert": {
        "type": "object",
        "description": "Custom DocType (ffl_core); CRUD via /api/resource/Customer%20Alert — see docs/api/frappe-rest.md.",
        "properties": {
          "message": {
            "type": "string",
            "description": "Message"
          },
          "active": {
            "type": "integer",
            "enum": [
              0,
              1
            ],
            "description": "Active"
          },
          "created_by": {
            "type": "string",
            "description": "Created By (Link: User)"
          },
          "created_on": {
            "type": "string",
            "description": "Created On"
          }
        },
        "required": [
          "message"
        ]
      },
      "Customer_Alias": {
        "type": "object",
        "description": "Custom DocType (ffl_core); CRUD via /api/resource/Customer%20Alias — see docs/api/frappe-rest.md.",
        "properties": {
          "alias_type": {
            "type": "string",
            "enum": [
              "Email",
              "GunBroker ID"
            ],
            "description": "Type"
          },
          "value": {
            "type": "string",
            "description": "Value"
          },
          "merged_from": {
            "type": "string",
            "description": "Merged From"
          },
          "merged_on": {
            "type": "string",
            "description": "Merged On"
          }
        },
        "required": [
          "alias_type",
          "value"
        ]
      },
      "Customer_ID_Document": {
        "type": "object",
        "description": "Custom DocType (ffl_core); CRUD via /api/resource/Customer%20ID%20Document — see docs/api/frappe-rest.md.",
        "properties": {
          "id_type": {
            "type": "string",
            "enum": [
              "Driver License",
              "State ID",
              "LEO",
              "Military",
              "Passport",
              "CCW",
              "Other"
            ],
            "description": "ID Type"
          },
          "id_number": {
            "type": "string",
            "description": "ID Number"
          },
          "issuing_authority": {
            "type": "string",
            "description": "Issued By"
          },
          "issue_date": {
            "type": "string",
            "description": "Issue Date"
          },
          "expiry_date": {
            "type": "string",
            "description": "Expiry Date"
          },
          "attachment": {
            "type": "string",
            "description": "Copy of ID"
          }
        },
        "required": [
          "id_type"
        ]
      },
      "FFL_Acquisition": {
        "type": "object",
        "description": "Custom DocType (ffl_core); CRUD via /api/resource/FFL%20Acquisition — see docs/api/frappe-rest.md.",
        "properties": {
          "acquisition_date": {
            "type": "string",
            "description": "Acquisition Date"
          },
          "source_type": {
            "type": "string",
            "enum": [
              "Individual",
              "FFL Dealer",
              "Manufacturer",
              "Importer",
              "Estate",
              "Pawn",
              "Trade-in"
            ],
            "description": "Source Type"
          },
          "company": {
            "type": "string",
            "description": "Company (Link: Company)"
          },
          "receive_source": {
            "type": "string",
            "description": "Receive Source"
          },
          "transaction_type": {
            "type": "string",
            "description": "Acquisition Type"
          },
          "amended_from": {
            "type": "string",
            "description": "Amended From (Link: FFL Acquisition)"
          },
          "source_name": {
            "type": "string",
            "description": "Source Name"
          },
          "source_first_name": {
            "type": "string",
            "description": "Source First Name"
          },
          "source_middle_name": {
            "type": "string",
            "description": "Source Middle Name"
          },
          "source_last_name": {
            "type": "string",
            "description": "Source Last Name"
          },
          "source_suffix": {
            "type": "string",
            "description": "Source Suffix"
          },
          "source_address": {
            "type": "string",
            "description": "Source Address"
          },
          "source_ffl": {
            "type": "string",
            "description": "Source FFL Number"
          },
          "source_id_type": {
            "type": "string",
            "enum": [
              "Driver License",
              "State ID",
              "Passport",
              "Military ID",
              "Other"
            ],
            "description": "ID Type"
          },
          "source_id_number": {
            "type": "string",
            "description": "ID Number"
          },
          "source_customer": {
            "type": "string",
            "description": "Seller (Customer) (Link: Customer)"
          },
          "transfer_for_customer": {
            "type": "string",
            "description": "Transfer For (Customer) (Link: Customer)"
          },
          "source_id_document": {
            "type": "string",
            "description": "ID Document"
          },
          "item": {
            "type": "string",
            "description": "Item (Link: Item)"
          },
          "serial": {
            "type": "string",
            "description": "Serial"
          },
          "ledger_serial": {
            "type": "string",
            "description": "Ledger Serial"
          },
          "cost": {
            "type": "number",
            "description": "Cost"
          },
          "fastbound_id": {
            "type": "string",
            "description": "FastBound ID"
          },
          "fastbound_synced_at": {
            "type": "string",
            "description": "Last Synced"
          },
          "pending_intake_payload": {
            "type": "string",
            "description": "Pending Intake Payload"
          },
          "notes": {
            "type": "string",
            "description": "Notes"
          }
        },
        "required": [
          "acquisition_date",
          "source_type",
          "company",
          "source_name",
          "item"
        ]
      },
      "FFL_Disposition": {
        "type": "object",
        "description": "Custom DocType (ffl_core); CRUD via /api/resource/FFL%20Disposition — see docs/api/frappe-rest.md.",
        "properties": {
          "disposition_date": {
            "type": "string",
            "description": "Disposition Date"
          },
          "disposition_type": {
            "type": "string",
            "enum": [
              "Retail Sale",
              "FFL Transfer",
              "Return",
              "Scrap",
              "Gunsmithing",
              "Dealer Transfer",
              "NFA"
            ],
            "description": "Disposition Type"
          },
          "company": {
            "type": "string",
            "description": "Company (Link: Company)"
          },
          "customer": {
            "type": "string",
            "description": "Customer (Link: Customer)"
          },
          "destination_ffl": {
            "type": "string",
            "description": "Destination FFL (Link: ATF FFL Record)"
          },
          "amended_from": {
            "type": "string",
            "description": "Amended From (Link: FFL Disposition)"
          },
          "destroyed_witness1": {
            "type": "string",
            "description": "Witness 1"
          },
          "destroyed_witness2": {
            "type": "string",
            "description": "Witness 2"
          },
          "item": {
            "type": "string",
            "description": "Item (Link: Item)"
          },
          "serial": {
            "type": "string",
            "description": "Serial"
          },
          "ledger_serial": {
            "type": "string",
            "description": "Ledger Serial"
          },
          "sales_invoice": {
            "type": "string",
            "description": "Sales Invoice (Link: Sales Invoice)"
          },
          "sales_order": {
            "type": "string",
            "description": "Sales Order (Link: Sales Order)"
          },
          "form_4473_status": {
            "type": "string",
            "enum": [
              "N/A",
              "Pending",
              "Completed"
            ],
            "description": "4473 Status"
          },
          "nics_status": {
            "type": "string",
            "enum": [
              "N/A",
              "Proceed",
              "Delayed",
              "Denied",
              "Cancelled"
            ],
            "description": "NICS Status"
          },
          "manual_override": {
            "type": "integer",
            "enum": [
              0,
              1
            ],
            "description": "Manual Override (4473 bypass)"
          },
          "override_reason": {
            "type": "string",
            "description": "Override Reason"
          },
          "override_by": {
            "type": "string",
            "description": "Override By (Link: User)"
          },
          "fastbound_id": {
            "type": "string",
            "description": "FastBound ID"
          },
          "fastbound_synced_at": {
            "type": "string",
            "description": "Last Synced"
          },
          "notes": {
            "type": "string",
            "description": "Notes"
          }
        },
        "required": [
          "disposition_date",
          "disposition_type",
          "company",
          "item"
        ]
      },
      "FFL_Settings": {
        "type": "object",
        "description": "Custom DocType (ffl_core); CRUD via /api/resource/FFL%20Settings — see docs/api/frappe-rest.md.",
        "properties": {
          "own_ffl_license": {
            "type": "string",
            "description": "Our FFL Licence Number"
          },
          "alert_recipients": {
            "type": "string",
            "description": "Alert Recipients"
          },
          "receive_sources": {
            "type": "string",
            "description": "Receive Sources"
          },
          "pending_order_age_alert_days": {
            "type": "integer",
            "description": "Pending Order overdue after (days)"
          },
          "counter_lock_minutes": {
            "type": "integer",
            "description": "Lock Idle Screen After (minutes)"
          },
          "require_price_approval": {
            "type": "integer",
            "enum": [
              0,
              1
            ],
            "description": "Require Manager Approval for Price Reductions"
          },
          "receipt_footer_note": {
            "type": "string",
            "description": "Receipt Footer Note"
          },
          "shipping_price_includes_tax": {
            "type": "integer",
            "enum": [
              0,
              1
            ],
            "description": "Shipping Price Includes Sales Tax"
          },
          "peace_officer_exempt_tax_account": {
            "type": "string",
            "description": "Peace-Officer Exempt Tax Account (Link: Account)"
          },
          "gunsmith_labor_item": {
            "type": "string",
            "description": "Gunsmith Labor Item (Link: Item)"
          },
          "gunsmith_agreement_template": {
            "type": "string",
            "description": "Intake Authorization (Link: Agreement Template)"
          },
          "paper_4473_mode": {
            "type": "integer",
            "enum": [
              0,
              1
            ],
            "description": "Paper 4473 Mode"
          },
          "store_customer_id_numbers": {
            "type": "integer",
            "enum": [
              0,
              1
            ],
            "description": "Store Customer ID Numbers"
          },
          "transfer_fee_item": {
            "type": "string",
            "description": "Transfer Fee Item (Link: Item)"
          },
          "transfer_fee_amount": {
            "type": "number",
            "description": "Default Transfer Fee"
          },
          "enforce_sale_agreements": {
            "type": "integer",
            "enum": [
              0,
              1
            ],
            "description": "Require Agreements at Sale"
          },
          "used_item_agreement_template": {
            "type": "string",
            "description": "Used Item Agreement (Link: Agreement Template)"
          },
          "serial_placeholders": {
            "type": "string",
            "description": "No-Serial Spellings"
          },
          "live_check_provider": {
            "type": "string",
            "enum": [
              "ATF Form Scraper",
              "Data Service",
              "Manual Only"
            ],
            "description": "Provider"
          },
          "live_check_rate_limit_per_hour": {
            "type": "integer",
            "description": "Rate Limit (req/hr)"
          },
          "live_check_cache_ttl_minutes": {
            "type": "integer",
            "description": "Cache TTL (minutes)"
          }
        }
      },
      "Form_4473_Log": {
        "type": "object",
        "description": "Custom DocType (ffl_core); CRUD via /api/resource/Form%204473%20Log — see docs/api/frappe-rest.md.",
        "properties": {
          "completed_on": {
            "type": "string",
            "description": "Completed On"
          },
          "source": {
            "type": "string",
            "enum": [
              "FastBound",
              "Paper / override"
            ],
            "description": "Source"
          },
          "nics_status": {
            "type": "string",
            "description": "NICS"
          },
          "pos_invoice": {
            "type": "string",
            "description": "POS Invoice(s)"
          },
          "customer": {
            "type": "string",
            "description": "Customer (Link: Customer)"
          },
          "customer_name": {
            "type": "string",
            "description": "Customer Name"
          },
          "serials": {
            "type": "string",
            "description": "Firearms (serials)"
          },
          "form4473_id": {
            "type": "string",
            "description": "FastBound 4473 ID"
          },
          "fastbound_disposition_id": {
            "type": "string",
            "description": "FastBound Disposition ID"
          },
          "pdf_url": {
            "type": "string",
            "description": "FastBound Download URL"
          },
          "pdf_status": {
            "type": "string",
            "enum": [
              "Pending",
              "Stored",
              "Not Found",
              "Failed",
              "No PDF"
            ],
            "description": "PDF Copy"
          },
          "pdf_file": {
            "type": "string",
            "description": "Signed 4473 PDF (private copy)"
          },
          "pdf_attempts": {
            "type": "integer",
            "description": "PDF Fetch Attempts"
          },
          "pdf_error": {
            "type": "string",
            "description": "Last PDF Fetch Error"
          }
        }
      },
      "Gunsmith_Work_Order": {
        "type": "object",
        "description": "Custom DocType (ffl_core); CRUD via /api/resource/Gunsmith%20Work%20Order — see docs/api/frappe-rest.md.",
        "properties": {
          "scan_id": {
            "type": "string",
            "description": "Scan ID"
          },
          "customer": {
            "type": "string",
            "description": "Customer (Link: Customer)"
          },
          "phone": {
            "type": "string",
            "description": "Phone"
          },
          "email": {
            "type": "string",
            "description": "Email"
          },
          "address_line1": {
            "type": "string",
            "description": "Street Address"
          },
          "city": {
            "type": "string",
            "description": "City"
          },
          "state": {
            "type": "string",
            "description": "State"
          },
          "zip": {
            "type": "string",
            "description": "ZIP"
          },
          "id_type": {
            "type": "string",
            "enum": [
              "Driver License",
              "State ID",
              "Passport",
              "Military ID",
              "Other"
            ],
            "description": "ID Type"
          },
          "id_number": {
            "type": "string",
            "description": "ID Number"
          },
          "id_document": {
            "type": "string",
            "description": "ID Scan"
          },
          "manufacturer": {
            "type": "string",
            "description": "Manufacturer"
          },
          "caliber": {
            "type": "string",
            "description": "Caliber / Gauge"
          },
          "model": {
            "type": "string",
            "description": "Model"
          },
          "firearm_type": {
            "type": "string",
            "enum": [
              "Pistol",
              "Revolver",
              "Rifle",
              "Shotgun",
              "Receiver",
              "Other Firearm",
              "Silencer",
              "Short Barreled Rifle",
              "Short Barreled Shotgun",
              "Machine Gun",
              "Destructive Device",
              "Any Other Weapon"
            ],
            "description": "Firearm Type"
          },
          "serial_number": {
            "type": "string",
            "description": "Serial Number"
          },
          "log_in_bound_book": {
            "type": "integer",
            "enum": [
              0,
              1
            ],
            "description": "Log in Bound Book"
          },
          "accessories": {
            "type": "string",
            "description": "Came In With"
          },
          "condition": {
            "type": "string",
            "description": "Condition"
          },
          "firearm_notes": {
            "type": "string",
            "description": "Notes"
          },
          "work_requested": {
            "type": "string",
            "description": "Work Requested"
          },
          "estimated_cost": {
            "type": "number",
            "description": "Estimate"
          },
          "estimated_completion": {
            "type": "string",
            "description": "Ready By"
          },
          "lines": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Gunsmith_Work_Order_Line"
            },
            "description": "Charges"
          },
          "scan_barcode": {
            "type": "string",
            "description": "Scan"
          },
          "final_cost": {
            "type": "number",
            "description": "Total Before Tax"
          },
          "gunsmith": {
            "type": "string",
            "description": "Gunsmith (Link: User)"
          },
          "work_performed": {
            "type": "string",
            "description": "Work Performed"
          },
          "completed_on": {
            "type": "string",
            "description": "Date Completed"
          },
          "notified_on": {
            "type": "string",
            "description": "Date Notified"
          },
          "picked_up_on": {
            "type": "string",
            "description": "Date Picked Up"
          },
          "notified_via": {
            "type": "string",
            "enum": [
              "Phone",
              "Email",
              "Text"
            ],
            "description": "Customer Notified By"
          },
          "notified_by": {
            "type": "string",
            "description": "Notified By (Link: User)"
          },
          "cancel_reason": {
            "type": "string",
            "description": "Cancel Reason"
          },
          "received_on": {
            "type": "string",
            "description": "Date Received"
          },
          "received_by": {
            "type": "string",
            "description": "Received By (Link: User)"
          },
          "company": {
            "type": "string",
            "description": "Company (Link: Company)"
          },
          "status": {
            "type": "string",
            "enum": [
              "Received",
              "In Progress",
              "Ready",
              "Picked Up",
              "Cancelled"
            ],
            "description": "Status"
          },
          "customer_name": {
            "type": "string",
            "description": "Customer Name"
          },
          "deposit_amount": {
            "type": "number",
            "description": "Paid at Intake"
          },
          "deposit_held": {
            "type": "number",
            "description": "Deposit Held"
          },
          "deposit_invoice": {
            "type": "string",
            "description": "Deposit Invoice (Link: POS Invoice)"
          },
          "pickup_invoice": {
            "type": "string",
            "description": "Pick-up Invoice (Link: POS Invoice)"
          },
          "intake_agreement": {
            "type": "string",
            "description": "Intake Authorization (Link: Customer Agreement)"
          },
          "purchase_receipt": {
            "type": "string",
            "description": "Custody Receipt (Link: Purchase Receipt)"
          },
          "item_code": {
            "type": "string",
            "description": "Item (Link: Item)"
          },
          "serial_no": {
            "type": "string",
            "description": "Serial No (Link: Serial No)"
          },
          "disposition": {
            "type": "string",
            "description": "Disposition (Link: FFL Disposition)"
          }
        },
        "required": [
          "customer",
          "manufacturer",
          "model",
          "serial_number",
          "work_requested",
          "received_on",
          "company"
        ]
      },
      "Gunsmith_Work_Order_Line": {
        "type": "object",
        "description": "Custom DocType (ffl_core); CRUD via /api/resource/Gunsmith%20Work%20Order%20Line — see docs/api/frappe-rest.md.",
        "properties": {
          "item_code": {
            "type": "string",
            "description": "Item (Link: Item)"
          },
          "description": {
            "type": "string",
            "description": "Description"
          },
          "qty": {
            "type": "number",
            "description": "Qty"
          },
          "rate": {
            "type": "number",
            "description": "Rate"
          },
          "amount": {
            "type": "number",
            "description": "Amount"
          }
        },
        "required": [
          "item_code",
          "qty"
        ]
      },
      "Inventory_Count": {
        "type": "object",
        "description": "Custom DocType (ffl_core); CRUD via /api/resource/Inventory%20Count — see docs/api/frappe-rest.md.",
        "properties": {
          "company": {
            "type": "string",
            "description": "Company (Link: Company)"
          },
          "status": {
            "type": "string",
            "enum": [
              "Open",
              "Finalized",
              "Cancelled"
            ],
            "description": "Status"
          },
          "include_custody": {
            "type": "integer",
            "enum": [
              0,
              1
            ],
            "description": "Include Customer-Custody Warehouses"
          },
          "notes": {
            "type": "string",
            "description": "Notes"
          },
          "warehouses": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Inventory_Count_Warehouse"
            },
            "description": "Warehouses"
          },
          "item_groups": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Inventory_Count_Item_Group"
            },
            "description": "Item Groups"
          },
          "stock_reconciliation": {
            "type": "string",
            "description": "Stock Reconciliation (Link: Stock Reconciliation)"
          },
          "finalized_by": {
            "type": "string",
            "description": "Finalized By (Link: User)"
          },
          "finalized_at": {
            "type": "string",
            "description": "Finalized At"
          },
          "serial_report": {
            "type": "string",
            "description": "Firearm Difference Report"
          }
        },
        "required": [
          "company"
        ]
      },
      "Inventory_Count_Entry": {
        "type": "object",
        "description": "Custom DocType (ffl_core); CRUD via /api/resource/Inventory%20Count%20Entry — see docs/api/frappe-rest.md.",
        "properties": {
          "inventory_count": {
            "type": "string",
            "description": "Inventory Count (Link: Inventory Count)"
          },
          "kind": {
            "type": "string",
            "enum": [
              "serial",
              "qty",
              "unknown"
            ],
            "description": "Kind"
          },
          "method": {
            "type": "string",
            "enum": [
              "scan",
              "manual"
            ],
            "description": "Entered By"
          },
          "item_code": {
            "type": "string",
            "description": "Item (Link: Item)"
          },
          "serial_no": {
            "type": "string",
            "description": "Serial No"
          },
          "code": {
            "type": "string",
            "description": "Scanned Code"
          },
          "warehouse": {
            "type": "string",
            "description": "Warehouse (Link: Warehouse)"
          },
          "qty_delta": {
            "type": "number",
            "description": "Quantity Change"
          },
          "serial_key": {
            "type": "string",
            "description": "Serial Key"
          }
        },
        "required": [
          "inventory_count",
          "kind"
        ]
      },
      "Inventory_Count_Item_Group": {
        "type": "object",
        "description": "Custom DocType (ffl_core); CRUD via /api/resource/Inventory%20Count%20Item%20Group — see docs/api/frappe-rest.md.",
        "properties": {
          "item_group": {
            "type": "string",
            "description": "Item Group (Link: Item Group)"
          }
        },
        "required": [
          "item_group"
        ]
      },
      "Inventory_Count_Warehouse": {
        "type": "object",
        "description": "Custom DocType (ffl_core); CRUD via /api/resource/Inventory%20Count%20Warehouse — see docs/api/frappe-rest.md.",
        "properties": {
          "warehouse": {
            "type": "string",
            "description": "Warehouse (Link: Warehouse)"
          }
        },
        "required": [
          "warehouse"
        ]
      },
      "Inventory_Import": {
        "type": "object",
        "description": "Custom DocType (ffl_core); CRUD via /api/resource/Inventory%20Import — see docs/api/frappe-rest.md.",
        "properties": {
          "csv_file": {
            "type": "string",
            "description": "CSV File"
          },
          "warehouse": {
            "type": "string",
            "description": "Warehouse (Link: Warehouse)"
          },
          "posting_date": {
            "type": "string",
            "description": "Cut-over Date"
          },
          "last_run": {
            "type": "string",
            "description": "Last Run"
          }
        },
        "required": [
          "posting_date"
        ]
      },
      "Item_Image_Gallery": {
        "type": "object",
        "description": "Custom DocType (ffl_core); CRUD via /api/resource/Item%20Image%20Gallery — see docs/api/frappe-rest.md.",
        "properties": {
          "image": {
            "type": "string",
            "description": "Image"
          },
          "is_primary": {
            "type": "integer",
            "enum": [
              0,
              1
            ],
            "description": "Primary"
          },
          "sort_order": {
            "type": "integer",
            "description": "Order"
          },
          "caption": {
            "type": "string",
            "description": "Caption"
          }
        },
        "required": [
          "image"
        ]
      },
      "Lead_Mail_Settings": {
        "type": "object",
        "description": "Custom DocType (ffl_core); CRUD via /api/resource/Lead%20Mail%20Settings — see docs/api/frappe-rest.md.",
        "properties": {
          "team_addresses": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Team_Mail_Address"
            },
            "description": "Team addresses"
          },
          "primary_team_address": {
            "type": "string",
            "description": "Reply-To for staff mail"
          },
          "blocked_sender_domains": {
            "type": "string",
            "description": "Blocked sender domains"
          },
          "own_domains": {
            "type": "string",
            "description": "Our own domains"
          },
          "category_rules": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/CRM_Mail_Category_Rule"
            },
            "description": "Category rules"
          },
          "spam_folder": {
            "type": "string",
            "description": "Spam folder"
          },
          "crm_pos_link": {
            "type": "integer",
            "enum": [
              0,
              1
            ],
            "description": "Link deals to POS orders"
          },
          "crm_deal_holds": {
            "type": "integer",
            "enum": [
              0,
              1
            ],
            "description": "Hold guns for deals"
          },
          "crm_daily_digest": {
            "type": "integer",
            "enum": [
              0,
              1
            ],
            "description": "Daily reply list"
          },
          "crm_digest_recipients": {
            "type": "string",
            "description": "Send it to everyone at"
          },
          "crm_wants_from_memory": {
            "type": "integer",
            "enum": [
              0,
              1
            ],
            "description": "Add wants from customer memory"
          },
          "crm_draft_on_arrival": {
            "type": "integer",
            "enum": [
              0,
              1
            ],
            "description": "Draft replies as mail arrives"
          }
        }
      },
      "MCP_Settings": {
        "type": "object",
        "description": "Custom DocType (ffl_core); CRUD via /api/resource/MCP%20Settings — see docs/api/frappe-rest.md.",
        "properties": {
          "enable_cpa": {
            "type": "integer",
            "enum": [
              0,
              1
            ],
            "description": "Enable Read-only MCP Server"
          },
          "cpa_url": {
            "type": "string",
            "description": "Read-only MCP Server URL"
          },
          "cpa_claude_code": {
            "type": "string",
            "description": "Claude Code Command (Read-only)"
          },
          "enable_full": {
            "type": "integer",
            "enum": [
              0,
              1
            ],
            "description": "Enable Full MCP Server"
          },
          "full_url": {
            "type": "string",
            "description": "Full MCP Server URL"
          },
          "full_claude_code": {
            "type": "string",
            "description": "Claude Code Command (Full)"
          },
          "enable_web_ro": {
            "type": "integer",
            "enum": [
              0,
              1
            ],
            "description": "Enable Website MCP Server"
          },
          "web_ro_url": {
            "type": "string",
            "description": "Website MCP Server URL"
          },
          "web_ro_claude_code": {
            "type": "string",
            "description": "Claude Code Command (Website)"
          }
        }
      },
      "Marketing_Automation": {
        "type": "object",
        "description": "Custom DocType (ffl_core); CRUD via /api/resource/Marketing%20Automation — see docs/api/frappe-rest.md.",
        "properties": {
          "key": {
            "type": "string",
            "description": "Automation"
          },
          "mode": {
            "type": "string",
            "enum": [
              "Off",
              "Dry run",
              "Live"
            ],
            "description": "Mode"
          }
        },
        "required": [
          "key",
          "mode"
        ]
      },
      "Marketing_Contact": {
        "type": "object",
        "description": "Custom DocType (ffl_core); CRUD via /api/resource/Marketing%20Contact — see docs/api/frappe-rest.md.",
        "properties": {
          "email": {
            "type": "string",
            "description": "Email"
          },
          "first_name": {
            "type": "string",
            "description": "First name"
          },
          "last_name": {
            "type": "string",
            "description": "Last name"
          },
          "customer": {
            "type": "string",
            "description": "Customer (Link: Customer)"
          },
          "status": {
            "type": "string",
            "enum": [
              "Not Subscribed",
              "Subscribed",
              "Unsubscribed",
              "Bounced",
              "Complained"
            ],
            "description": "Status"
          },
          "source": {
            "type": "string",
            "description": "Source"
          },
          "consent_at": {
            "type": "string",
            "description": "Consent given"
          },
          "consent_channel": {
            "type": "string",
            "description": "Consent channel"
          },
          "status_changed_at": {
            "type": "string",
            "description": "Status changed"
          },
          "status_reason": {
            "type": "string",
            "description": "Status reason"
          },
          "legacy_hash": {
            "type": "string",
            "description": "Unsubscribe link key"
          },
          "legacy_hash_2": {
            "type": "string",
            "description": "Unsubscribe link key 2"
          }
        },
        "required": [
          "email",
          "status"
        ]
      },
      "Marketing_Event": {
        "type": "object",
        "description": "Custom DocType (ffl_core); CRUD via /api/resource/Marketing%20Event — see docs/api/frappe-rest.md.",
        "properties": {
          "contact": {
            "type": "string",
            "description": "Contact (Link: Marketing Contact)"
          },
          "kind": {
            "type": "string",
            "enum": [
              "Subscribed",
              "Unsubscribed",
              "Bounced",
              "Complained",
              "Requested",
              "Sent",
              "Skipped",
              "Opened",
              "Clicked",
              "Imported"
            ],
            "description": "Kind"
          },
          "occurred_at": {
            "type": "string",
            "description": "When"
          },
          "mail": {
            "type": "string",
            "description": "Mail"
          },
          "campaign": {
            "type": "string",
            "description": "Campaign"
          },
          "dedupe_key": {
            "type": "string",
            "description": "Dedupe key"
          },
          "detail": {
            "type": "string",
            "description": "Detail"
          }
        },
        "required": [
          "contact",
          "kind",
          "occurred_at"
        ]
      },
      "Marketing_Request": {
        "type": "object",
        "description": "Custom DocType (ffl_core); CRUD via /api/resource/Marketing%20Request — see docs/api/frappe-rest.md.",
        "properties": {
          "contact": {
            "type": "string",
            "description": "Contact (Link: Marketing Contact)"
          },
          "kind": {
            "type": "string",
            "enum": [
              "Back in stock",
              "Model alert"
            ],
            "description": "Kind"
          },
          "status": {
            "type": "string",
            "enum": [
              "Open",
              "Notified",
              "Closed"
            ],
            "description": "Status"
          },
          "label": {
            "type": "string",
            "description": "Product or model"
          },
          "item": {
            "type": "string",
            "description": "Item (Link: Item)"
          },
          "sku": {
            "type": "string",
            "description": "SKU"
          },
          "web_product_id": {
            "type": "string",
            "description": "Website product ID"
          },
          "model_key": {
            "type": "string",
            "description": "Model key"
          },
          "url": {
            "type": "string",
            "description": "URL"
          },
          "requested_at": {
            "type": "string",
            "description": "Requested"
          },
          "notified_at": {
            "type": "string",
            "description": "Notified"
          }
        },
        "required": [
          "contact",
          "kind",
          "status"
        ]
      },
      "Marketing_Settings": {
        "type": "object",
        "description": "Custom DocType (ffl_core); CRUD via /api/resource/Marketing%20Settings — see docs/api/frappe-rest.md.",
        "properties": {
          "enabled": {
            "type": "integer",
            "enum": [
              0,
              1
            ],
            "description": "Enabled"
          },
          "auto_subscribe_customers": {
            "type": "integer",
            "enum": [
              0,
              1
            ],
            "description": "Subscribe store customers"
          },
          "email_account": {
            "type": "string",
            "description": "Email account (Link: Email Account)"
          },
          "reply_to": {
            "type": "string",
            "description": "Reply-To"
          },
          "track_opens": {
            "type": "integer",
            "enum": [
              0,
              1
            ],
            "description": "Track opens"
          },
          "track_clicks": {
            "type": "integer",
            "enum": [
              0,
              1
            ],
            "description": "Track clicks"
          },
          "sns_topic_arn": {
            "type": "string",
            "description": "SNS topic ARN"
          },
          "automations": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Marketing_Automation"
            },
            "description": "Automations"
          }
        }
      },
      "Membership": {
        "type": "object",
        "description": "Custom DocType (ffl_core); CRUD via /api/resource/Membership — see docs/api/frappe-rest.md.",
        "properties": {
          "customer": {
            "type": "string",
            "description": "Customer (Link: Customer)"
          },
          "customer_name": {
            "type": "string",
            "description": "Customer Name"
          },
          "plan": {
            "type": "string",
            "description": "Plan (Link: Membership Plan)"
          },
          "status": {
            "type": "string",
            "enum": [
              "Pending",
              "Active",
              "Past Due",
              "Suspended",
              "Cancelled",
              "Expired"
            ],
            "description": "Status"
          },
          "start_date": {
            "type": "string",
            "description": "Member Since"
          },
          "current_period_start": {
            "type": "string",
            "description": "Current Period Start"
          },
          "current_period_end": {
            "type": "string",
            "description": "Current Period End"
          },
          "company": {
            "type": "string",
            "description": "Company (Link: Company)"
          },
          "auto_renew": {
            "type": "integer",
            "enum": [
              0,
              1
            ],
            "description": "Auto-renew"
          },
          "saved_card": {
            "type": "string",
            "description": "Saved Card (Link: Saved Card)"
          },
          "grace_until": {
            "type": "string",
            "description": "Grace Until"
          },
          "last_charge_status": {
            "type": "string",
            "description": "Last Charge"
          },
          "last_charge_attempt": {
            "type": "string",
            "description": "Last Renewal Attempt"
          },
          "renewal_reminder_for": {
            "type": "string",
            "description": "Renewal Reminder Sent For"
          },
          "cancel_at_period_end": {
            "type": "integer",
            "enum": [
              0,
              1
            ],
            "description": "Ends at Period End"
          },
          "cancelled_on": {
            "type": "string",
            "description": "Cancelled On"
          },
          "cancelled_by": {
            "type": "string",
            "description": "Cancelled By (Link: User)"
          },
          "cancel_reason": {
            "type": "string",
            "description": "Cancellation Reason"
          },
          "invoices": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Membership_Invoice"
            },
            "description": "Invoices"
          }
        },
        "required": [
          "customer",
          "plan"
        ]
      },
      "Membership_Invoice": {
        "type": "object",
        "description": "Custom DocType (ffl_core); CRUD via /api/resource/Membership%20Invoice — see docs/api/frappe-rest.md.",
        "properties": {
          "sales_invoice": {
            "type": "string",
            "description": "Sales Invoice (Link: Sales Invoice)"
          },
          "period_start": {
            "type": "string",
            "description": "Period Start"
          },
          "period_end": {
            "type": "string",
            "description": "Period End"
          },
          "status": {
            "type": "string",
            "enum": [
              "Unpaid",
              "Paid",
              "Cancelled"
            ],
            "description": "Status"
          },
          "credit_note": {
            "type": "string",
            "description": "Credit Note (Link: Sales Invoice)"
          }
        }
      },
      "Membership_Plan": {
        "type": "object",
        "description": "Custom DocType (ffl_core); CRUD via /api/resource/Membership%20Plan — see docs/api/frappe-rest.md.",
        "properties": {
          "plan_name": {
            "type": "string",
            "description": "Plan Name"
          },
          "active": {
            "type": "integer",
            "enum": [
              0,
              1
            ],
            "description": "Active"
          },
          "billing_period": {
            "type": "string",
            "enum": [
              "Monthly",
              "Yearly"
            ],
            "description": "Billing Period"
          },
          "price": {
            "type": "number",
            "description": "Price per Period"
          },
          "item": {
            "type": "string",
            "description": "Billed Item (Link: Item)"
          },
          "description": {
            "type": "string",
            "description": "Description"
          },
          "registration_item": {
            "type": "string",
            "description": "Registration Item (Link: Item)"
          },
          "registration_fee": {
            "type": "number",
            "description": "Registration Fee"
          },
          "auto_renew_default": {
            "type": "integer",
            "enum": [
              0,
              1
            ],
            "description": "Auto-renew by Default"
          },
          "terms_template": {
            "type": "string",
            "description": "Membership Terms (Link: Agreement Template)"
          },
          "grace_enabled": {
            "type": "integer",
            "enum": [
              0,
              1
            ],
            "description": "Grace Period on Failed Renewal"
          },
          "grace_days": {
            "type": "integer",
            "description": "Grace Days"
          },
          "benefits": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Membership_Plan_Benefit"
            },
            "description": "Benefits"
          }
        },
        "required": [
          "plan_name",
          "billing_period",
          "price"
        ]
      },
      "Membership_Plan_Benefit": {
        "type": "object",
        "description": "Custom DocType (ffl_core); CRUD via /api/resource/Membership%20Plan%20Benefit — see docs/api/frappe-rest.md.",
        "properties": {
          "applies_to": {
            "type": "string",
            "enum": [
              "Item",
              "Item Group",
              "Price List"
            ],
            "description": "Applies To"
          },
          "item": {
            "type": "string",
            "description": "Item (Link: Item)"
          },
          "item_group": {
            "type": "string",
            "description": "Item Group (with Sub-groups) (Link: Item Group)"
          },
          "price_list": {
            "type": "string",
            "description": "Items Priced in Price List (Link: Price List)"
          },
          "benefit_type": {
            "type": "string",
            "enum": [
              "Percent off",
              "Amount off",
              "Fixed price",
              "Price-list price"
            ],
            "description": "Benefit"
          },
          "value": {
            "type": "number",
            "description": "Percent, Amount or Price"
          },
          "uses_per_day": {
            "type": "integer",
            "description": "Daily Limit per Member (0 = None)"
          },
          "days": {
            "type": "string",
            "description": "Only on Days"
          },
          "label": {
            "type": "string",
            "description": "Reason Shown on the Sale"
          }
        },
        "required": [
          "applies_to",
          "benefit_type"
        ]
      },
      "Membership_Settings": {
        "type": "object",
        "description": "Custom DocType (ffl_core); CRUD via /api/resource/Membership%20Settings — see docs/api/frappe-rest.md.",
        "properties": {
          "auto_renew_enabled": {
            "type": "integer",
            "enum": [
              0,
              1
            ],
            "description": "Charge renewals automatically"
          },
          "yearly_reminder_days": {
            "type": "integer",
            "description": "Yearly renewal reminder (days before)"
          }
        }
      },
      "POS_Extension": {
        "type": "object",
        "description": "Custom DocType (ffl_core); CRUD via /api/resource/POS%20Extension — see docs/api/frappe-rest.md.",
        "properties": {
          "extension_id": {
            "type": "string",
            "description": "Extension ID"
          },
          "title": {
            "type": "string",
            "description": "Title"
          },
          "version": {
            "type": "string",
            "description": "Version"
          },
          "enabled": {
            "type": "integer",
            "enum": [
              0,
              1
            ],
            "description": "Enabled"
          },
          "installed_on_site": {
            "type": "integer",
            "enum": [
              0,
              1
            ],
            "description": "Installed on this site"
          },
          "compatible": {
            "type": "integer",
            "enum": [
              0,
              1
            ],
            "description": "Compatible with this core"
          },
          "incompatible_reason": {
            "type": "string",
            "description": "Why not compatible"
          },
          "latest_version": {
            "type": "string",
            "description": "Newer Version Offered"
          },
          "latest_requires_core": {
            "type": "string",
            "description": "It Requires Core"
          },
          "latest_sha256": {
            "type": "string",
            "description": "Its SHA-256"
          },
          "latest_checked_at": {
            "type": "string",
            "description": "Last Checked For Updates"
          },
          "publisher": {
            "type": "string",
            "description": "Publisher"
          },
          "publisher_id": {
            "type": "string",
            "description": "Publisher ID"
          },
          "license_required": {
            "type": "integer",
            "enum": [
              0,
              1
            ],
            "description": "Needs a licence (marketplace)"
          },
          "source": {
            "type": "string",
            "description": "Source"
          },
          "installed_at": {
            "type": "string",
            "description": "Installed at"
          },
          "installed_by": {
            "type": "string",
            "description": "Installed by"
          },
          "description": {
            "type": "string",
            "description": "Description"
          },
          "requires_core": {
            "type": "string",
            "description": "Requires core"
          },
          "homepage": {
            "type": "string",
            "description": "Homepage"
          },
          "support": {
            "type": "string",
            "description": "Support"
          },
          "permissions": {
            "type": "string",
            "description": "Permissions (declared)"
          },
          "manifest": {
            "type": "string",
            "description": "Manifest snapshot"
          },
          "job_state": {
            "type": "string",
            "enum": [
              "Idle",
              "Installing",
              "Staged",
              "Upgrading",
              "Uninstalling",
              "Failed"
            ],
            "description": "Job"
          },
          "job_started_at": {
            "type": "string",
            "description": "Job started at"
          },
          "job_message": {
            "type": "string",
            "description": "Job message"
          },
          "last_synced": {
            "type": "string",
            "description": "Last synced"
          }
        },
        "required": [
          "extension_id"
        ]
      },
      "Signing_Terminal": {
        "type": "object",
        "description": "Custom DocType (ffl_core); CRUD via /api/resource/Signing%20Terminal — see docs/api/frappe-rest.md.",
        "properties": {
          "terminal_name": {
            "type": "string",
            "description": "Tablet Name"
          },
          "active": {
            "type": "integer",
            "enum": [
              0,
              1
            ],
            "description": "Active"
          },
          "pos_profile": {
            "type": "string",
            "description": "Register (Link: POS Profile)"
          },
          "paired_on": {
            "type": "string",
            "description": "Paired On"
          },
          "paired_by": {
            "type": "string",
            "description": "Paired By (Link: User)"
          },
          "last_seen": {
            "type": "string",
            "description": "Last Seen"
          },
          "device_secret_hash": {
            "type": "string",
            "description": "Device Key (hash)"
          }
        },
        "required": [
          "terminal_name"
        ]
      },
      "Storage_Floor_Plan": {
        "type": "object",
        "description": "Custom DocType (ffl_core); CRUD via /api/resource/Storage%20Floor%20Plan — see docs/api/frappe-rest.md.",
        "properties": {
          "company": {
            "type": "string",
            "description": "Company (Link: Company)"
          },
          "plan_name": {
            "type": "string",
            "description": "Plan"
          },
          "width": {
            "type": "number",
            "description": "Width (ft)"
          },
          "height": {
            "type": "number",
            "description": "Depth (ft)"
          },
          "layout": {
            "type": "string",
            "description": "Layout"
          }
        },
        "required": [
          "company",
          "plan_name"
        ]
      },
      "Storage_Location": {
        "type": "object",
        "description": "Custom DocType (ffl_core); CRUD via /api/resource/Storage%20Location — see docs/api/frappe-rest.md.",
        "properties": {
          "company": {
            "type": "string",
            "description": "Company (Link: Company)"
          },
          "zone": {
            "type": "string",
            "description": "Zone (Link: Storage Zone)"
          },
          "label": {
            "type": "string",
            "description": "Label"
          },
          "position": {
            "type": "integer",
            "description": "Position"
          },
          "kind": {
            "type": "string",
            "enum": [
              "Slots",
              "Open"
            ],
            "description": "Kind"
          },
          "disabled": {
            "type": "integer",
            "enum": [
              0,
              1
            ],
            "description": "Disabled"
          }
        },
        "required": [
          "company",
          "zone",
          "label"
        ]
      },
      "Storage_Location_Qty": {
        "type": "object",
        "description": "Custom DocType (ffl_core); CRUD via /api/resource/Storage%20Location%20Qty — see docs/api/frappe-rest.md.",
        "properties": {
          "location": {
            "type": "string",
            "description": "Location (Link: Storage Location)"
          },
          "item_code": {
            "type": "string",
            "description": "Item (Link: Item)"
          },
          "qty": {
            "type": "number",
            "description": "Quantity"
          },
          "company": {
            "type": "string",
            "description": "Company (Link: Company)"
          }
        },
        "required": [
          "location",
          "item_code",
          "company"
        ]
      },
      "Storage_Move": {
        "type": "object",
        "description": "Custom DocType (ffl_core); CRUD via /api/resource/Storage%20Move — see docs/api/frappe-rest.md.",
        "properties": {
          "serial_no": {
            "type": "string",
            "description": "Serial No"
          },
          "item_code": {
            "type": "string",
            "description": "Item (Link: Item)"
          },
          "qty": {
            "type": "number",
            "description": "Quantity"
          },
          "company": {
            "type": "string",
            "description": "Company (Link: Company)"
          },
          "from_location": {
            "type": "string",
            "description": "From (Link: Storage Location)"
          },
          "to_location": {
            "type": "string",
            "description": "To (Link: Storage Location)"
          },
          "kind": {
            "type": "string",
            "enum": [
              "serial",
              "qty"
            ],
            "description": "Kind"
          },
          "reason": {
            "type": "string",
            "enum": [
              "receive",
              "move",
              "sale",
              "ship",
              "out",
              "return",
              "count",
              "adjust",
              "confirm"
            ],
            "description": "Reason"
          },
          "voucher_type": {
            "type": "string",
            "description": "Document Type"
          },
          "voucher_no": {
            "type": "string",
            "description": "Document"
          },
          "voucher_detail": {
            "type": "string",
            "description": "Document Row"
          },
          "note": {
            "type": "string",
            "description": "Note"
          }
        },
        "required": [
          "kind",
          "reason"
        ]
      },
      "Storage_Zone": {
        "type": "object",
        "description": "Custom DocType (ffl_core); CRUD via /api/resource/Storage%20Zone — see docs/api/frappe-rest.md.",
        "properties": {
          "zone_name": {
            "type": "string",
            "description": "Zone"
          },
          "kind": {
            "type": "string",
            "enum": [
              "Slots",
              "Open"
            ],
            "description": "Kind"
          },
          "slot_count": {
            "type": "integer",
            "description": "Positions"
          },
          "company": {
            "type": "string",
            "description": "Company (Link: Company)"
          },
          "slot_lines": {
            "type": "integer",
            "description": "Sides"
          },
          "numbering": {
            "type": "string",
            "enum": [
              "Odd / even",
              "In order"
            ],
            "description": "Numbering"
          },
          "sort_order": {
            "type": "integer",
            "description": "Sort Order"
          },
          "disabled": {
            "type": "integer",
            "enum": [
              0,
              1
            ],
            "description": "Disabled"
          }
        },
        "required": [
          "zone_name",
          "kind",
          "company"
        ]
      },
      "Team_Mail_Address": {
        "type": "object",
        "description": "Custom DocType (ffl_core); CRUD via /api/resource/Team%20Mail%20Address — see docs/api/frappe-rest.md.",
        "properties": {
          "address": {
            "type": "string",
            "description": "Address"
          },
          "address_type": {
            "type": "string",
            "enum": [
              "Group",
              "Mailbox"
            ],
            "description": "Type"
          },
          "collector": {
            "type": "string",
            "description": "Collected by (Link: Email Account)"
          },
          "assignment": {
            "type": "string",
            "enum": [
              "Pool",
              "Round robin"
            ],
            "description": "New leads"
          }
        },
        "required": [
          "address",
          "address_type"
        ]
      },
      "Card_Charge": {
        "type": "object",
        "description": "Custom DocType (ffl_integrations); CRUD via /api/resource/Card%20Charge — see docs/api/frappe-rest.md.",
        "properties": {
          "amount": {
            "type": "number",
            "description": "Captured Amount"
          },
          "status": {
            "type": "string",
            "enum": [
              "IN_PROGRESS",
              "CHARGED",
              "DECLINED",
              "CANCELED",
              "VOIDED",
              "REFUNDED"
            ],
            "description": "Status"
          },
          "card_summary": {
            "type": "string",
            "description": "Card"
          },
          "unique_reference": {
            "type": "string",
            "description": "Gateway Reference"
          },
          "refunded_amount": {
            "type": "number",
            "description": "Refunded Amount"
          },
          "attempt": {
            "type": "integer",
            "description": "Attempt"
          },
          "processor": {
            "type": "string",
            "description": "Processor"
          },
          "card_reader": {
            "type": "string",
            "description": "Card Reader"
          },
          "device_serial_number": {
            "type": "string",
            "description": "Device Serial Number"
          },
          "instruction_id": {
            "type": "string",
            "description": "Instruction ID"
          },
          "response": {
            "type": "string",
            "description": "Gateway Response"
          },
          "save_card": {
            "type": "integer",
            "enum": [
              0,
              1
            ],
            "description": "Save Card Requested"
          },
          "save_reference": {
            "type": "string",
            "description": "Saved Card Reference"
          },
          "saved_card": {
            "type": "string",
            "description": "Saved Card (Link: Saved Card)"
          }
        }
      },
      "Card_On_File_Settings": {
        "type": "object",
        "description": "Custom DocType (ffl_integrations); CRUD via /api/resource/Card%20On%20File%20Settings — see docs/api/frappe-rest.md.",
        "properties": {
          "card_on_file_enabled": {
            "type": "integer",
            "enum": [
              0,
              1
            ],
            "description": "Offer to Save Cards"
          },
          "card_on_file_template": {
            "type": "string",
            "description": "Card-on-File Authorization (Link: Agreement Template)"
          }
        }
      },
      "Card_Reader": {
        "type": "object",
        "description": "Custom DocType (ffl_integrations); CRUD via /api/resource/Card%20Reader — see docs/api/frappe-rest.md.",
        "properties": {
          "reader_name": {
            "type": "string",
            "description": "Reader Name"
          },
          "serial_number": {
            "type": "string",
            "description": "Device Serial Number"
          },
          "enabled": {
            "type": "integer",
            "enum": [
              0,
              1
            ],
            "description": "Enabled"
          }
        },
        "required": [
          "reader_name",
          "serial_number"
        ]
      },
      "Card_Terminal_Payment": {
        "type": "object",
        "description": "Custom DocType (ffl_integrations); CRUD via /api/resource/Card%20Terminal%20Payment — see docs/api/frappe-rest.md.",
        "properties": {
          "sales_invoice": {
            "type": "string",
            "description": "Sales Invoice (Link: Sales Invoice)"
          },
          "gunbroker_order": {
            "type": "string",
            "description": "GunBroker Order (Link: GunBroker Order)"
          },
          "amount": {
            "type": "number",
            "description": "Amount"
          },
          "status": {
            "type": "string",
            "enum": [
              "IN_PROGRESS",
              "CHARGED",
              "DECLINED",
              "CANCELED",
              "VOIDED",
              "REFUNDED"
            ],
            "description": "Status"
          },
          "card_summary": {
            "type": "string",
            "description": "Card"
          },
          "approval_code": {
            "type": "string",
            "description": "Approval Code"
          },
          "unique_reference": {
            "type": "string",
            "description": "Gateway Reference"
          },
          "payment_entry": {
            "type": "string",
            "description": "Payment Entry (Link: Payment Entry)"
          },
          "refunded_amount": {
            "type": "number",
            "description": "Refunded"
          },
          "reversal_entry_type": {
            "type": "string",
            "description": "Reversal Entry Type (Link: DocType)"
          },
          "reversal_entry": {
            "type": "string",
            "description": "Void Entry (Link: reversal_entry_type)"
          },
          "reversal_lock": {
            "type": "string",
            "description": "Unconfirmed Void / Refund"
          },
          "processor": {
            "type": "string",
            "description": "Processor"
          },
          "card_reader": {
            "type": "string",
            "description": "Card Reader"
          },
          "device_serial_number": {
            "type": "string",
            "description": "Device Serial Number"
          },
          "instruction_id": {
            "type": "string",
            "description": "Instruction ID"
          },
          "response": {
            "type": "string",
            "description": "Gateway Response"
          },
          "save_card": {
            "type": "integer",
            "enum": [
              0,
              1
            ],
            "description": "Save Card Requested"
          },
          "save_reference": {
            "type": "string",
            "description": "Saved Card Reference"
          },
          "save_usage": {
            "type": "string",
            "description": "Saved Card Usage"
          },
          "saved_card": {
            "type": "string",
            "description": "Saved Card (Link: Saved Card)"
          }
        }
      },
      "Data_Service_Settings": {
        "type": "object",
        "description": "Custom DocType (ffl_integrations); CRUD via /api/resource/Data%20Service%20Settings — see docs/api/frappe-rest.md.",
        "properties": {
          "catalog_source": {
            "type": "string",
            "enum": [
              "Data Service",
              "Local"
            ],
            "description": "Catalog source"
          },
          "endpoint": {
            "type": "string",
            "description": "Endpoint"
          },
          "client_id": {
            "type": "string",
            "description": "Client ID"
          },
          "secret": {
            "type": "string",
            "description": "Secret"
          },
          "contract_version": {
            "type": "string",
            "description": "Catalog API contract"
          },
          "last_checked_at": {
            "type": "string",
            "description": "Checked at"
          },
          "last_error": {
            "type": "string",
            "description": "Last error"
          },
          "category_mirror": {
            "type": "string",
            "enum": [
              "Off",
              "Report only",
              "Apply"
            ],
            "description": "Mode"
          },
          "category_mirror_run_at": {
            "type": "string",
            "description": "Last run"
          },
          "category_mirror_issues": {
            "type": "integer",
            "description": "Could not link"
          },
          "category_tree_cursor": {
            "type": "string",
            "description": "Tree cursor"
          },
          "category_products_cursor": {
            "type": "string",
            "description": "Product changes cursor"
          },
          "category_products_baselined": {
            "type": "integer",
            "enum": [
              0,
              1
            ],
            "description": "Product changes baselined"
          },
          "category_mirror_report": {
            "type": "string",
            "description": "Report"
          }
        }
      },
      "Distributor": {
        "type": "object",
        "description": "Custom DocType (ffl_integrations); CRUD via /api/resource/Distributor — see docs/api/frappe-rest.md.",
        "properties": {
          "code": {
            "type": "string",
            "description": "Code"
          },
          "distributor_name": {
            "type": "string",
            "description": "Name"
          },
          "provider": {
            "type": "string",
            "description": "Provider"
          },
          "supplier": {
            "type": "string",
            "description": "Supplier (Link: Supplier)"
          },
          "enabled": {
            "type": "integer",
            "enum": [
              0,
              1
            ],
            "description": "Enabled"
          },
          "dropship_enabled": {
            "type": "integer",
            "enum": [
              0,
              1
            ],
            "description": "Drop-ship"
          },
          "stocking_enabled": {
            "type": "integer",
            "enum": [
              0,
              1
            ],
            "description": "Stocking"
          },
          "poll_enabled": {
            "type": "integer",
            "enum": [
              0,
              1
            ],
            "description": "Poll orders"
          },
          "priority": {
            "type": "integer",
            "description": "Priority"
          },
          "notes": {
            "type": "string",
            "description": "Notes"
          },
          "override_dropship_defaults": {
            "type": "integer",
            "enum": [
              0,
              1
            ],
            "description": "Use its own markup and stock settings"
          },
          "default_markup_pct": {
            "type": "number",
            "description": "Default markup %"
          },
          "default_rounding": {
            "type": "string",
            "enum": [
              ".99",
              "none",
              "whole"
            ],
            "description": "Rounding"
          },
          "markup_rules": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Distributor_Markup_Rule"
            },
            "description": "Markup rules (retired)"
          },
          "lead_days_min": {
            "type": "integer",
            "description": "Lead time (business days, from)"
          },
          "safety_buffer": {
            "type": "integer",
            "description": "Safety buffer"
          },
          "display_cap": {
            "type": "integer",
            "description": "Display cap"
          },
          "lead_days_max": {
            "type": "integer",
            "description": "Lead time (business days, to)"
          },
          "zero_stock_when_feed_stale": {
            "type": "integer",
            "enum": [
              0,
              1
            ],
            "description": "Zero stock when the feed is stale"
          },
          "catalog_endpoint": {
            "type": "string",
            "description": "Endpoint"
          },
          "catalog_client_id": {
            "type": "string",
            "description": "Client ID"
          },
          "catalog_secret": {
            "type": "string",
            "description": "Secret"
          },
          "last_poll_run_at": {
            "type": "string",
            "description": "Last order poll"
          }
        },
        "required": [
          "code",
          "provider"
        ]
      },
      "Distributor_Invoice": {
        "type": "object",
        "description": "Custom DocType (ffl_integrations); CRUD via /api/resource/Distributor%20Invoice — see docs/api/frappe-rest.md.",
        "properties": {
          "distributor": {
            "type": "string",
            "description": "Distributor (Link: Distributor)"
          },
          "invoice_number": {
            "type": "string",
            "description": "Invoice Number"
          },
          "invoice_date": {
            "type": "string",
            "description": "Invoice Date"
          },
          "account": {
            "type": "string",
            "description": "Account"
          },
          "po_number": {
            "type": "string",
            "description": "PO Number"
          },
          "order_ref": {
            "type": "string",
            "description": "Distributor Order Number"
          },
          "distributor_order": {
            "type": "string",
            "description": "Distributor Order (Link: Distributor Order)"
          },
          "outside_pos": {
            "type": "integer",
            "enum": [
              0,
              1
            ],
            "description": "Placed Outside POS"
          },
          "destination": {
            "type": "string",
            "enum": [
              "Store",
              "Drop-ship",
              "Unknown"
            ],
            "description": "Destination"
          },
          "destination_note": {
            "type": "string",
            "enum": [
              "Lookup failed",
              "No answer on file"
            ],
            "description": "Destination Note"
          },
          "received": {
            "type": "integer",
            "enum": [
              0,
              1
            ],
            "description": "Received"
          },
          "received_receipts": {
            "type": "string",
            "description": "Purchase Receipts"
          },
          "tracking_numbers": {
            "type": "string",
            "description": "Tracking Numbers"
          },
          "lines": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Distributor_Invoice_Line"
            },
            "description": "Lines"
          },
          "total": {
            "type": "number",
            "description": "Invoice Total"
          },
          "freight": {
            "type": "number",
            "description": "Freight"
          },
          "fees": {
            "type": "number",
            "description": "Fees"
          }
        },
        "required": [
          "distributor",
          "invoice_number"
        ]
      },
      "Distributor_Invoice_Line": {
        "type": "object",
        "description": "Custom DocType (ffl_integrations); CRUD via /api/resource/Distributor%20Invoice%20Line — see docs/api/frappe-rest.md.",
        "properties": {
          "sku": {
            "type": "string",
            "description": "SKU"
          },
          "description": {
            "type": "string",
            "description": "Description"
          },
          "qty": {
            "type": "integer",
            "description": "Qty"
          },
          "unit_cost": {
            "type": "number",
            "description": "Unit Cost"
          },
          "amount": {
            "type": "number",
            "description": "Amount"
          },
          "tracking_number": {
            "type": "string",
            "description": "Tracking Number"
          },
          "serials": {
            "type": "string",
            "description": "Serials"
          },
          "item_code": {
            "type": "string",
            "description": "Item (Link: Item)"
          },
          "received_qty": {
            "type": "integer",
            "description": "Received Qty"
          },
          "upc": {
            "type": "string",
            "description": "UPC"
          }
        }
      },
      "Distributor_Markup_Rule": {
        "type": "object",
        "description": "Custom DocType (ffl_integrations); CRUD via /api/resource/Distributor%20Markup%20Rule — see docs/api/frappe-rest.md.",
        "properties": {
          "rule_scope": {
            "type": "string",
            "enum": [
              "Department",
              "Brand"
            ],
            "description": "Scope"
          },
          "dept_pattern": {
            "type": "string",
            "description": "Department Pattern"
          },
          "brand": {
            "type": "string",
            "description": "Brand (Link: Brand)"
          },
          "markup_pct": {
            "type": "number",
            "description": "Markup %"
          },
          "markup_flat": {
            "type": "number",
            "description": "Markup Flat"
          },
          "rounding": {
            "type": "string",
            "enum": [
              ".99",
              "none",
              "whole"
            ],
            "description": "Rounding"
          },
          "note": {
            "type": "string",
            "description": "Note"
          }
        },
        "required": [
          "rule_scope"
        ]
      },
      "Distributor_Order": {
        "type": "object",
        "description": "Custom DocType (ffl_integrations); CRUD via /api/resource/Distributor%20Order — see docs/api/frappe-rest.md.",
        "properties": {
          "naming_series": {
            "type": "string",
            "enum": [
              "DO-.YY..MM.-.####"
            ],
            "description": "Series"
          },
          "distributor": {
            "type": "string",
            "description": "Distributor (Link: Distributor)"
          },
          "order_type": {
            "type": "string",
            "enum": [
              "Stocking",
              "Dropship Accessory",
              "Dropship Firearm",
              "Procure To Store"
            ],
            "description": "Order Type"
          },
          "account": {
            "type": "string",
            "enum": [
              "dealer",
              "fulfillment"
            ],
            "description": "Lane Account"
          },
          "account_number": {
            "type": "string",
            "description": "Account"
          },
          "company": {
            "type": "string",
            "description": "Company (Link: Company)"
          },
          "status": {
            "type": "string",
            "enum": [
              "Draft",
              "Queued",
              "Placed",
              "Acknowledged",
              "Hold",
              "Partially Shipped",
              "Complete",
              "Cancelled",
              "Error"
            ],
            "description": "Status"
          },
          "web_ref": {
            "type": "string",
            "description": "Distributor Order No."
          },
          "hold_status": {
            "type": "string",
            "description": "Hold Status"
          },
          "hold_reason": {
            "type": "string",
            "description": "Hold / Cancel Reason"
          },
          "lines": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Distributor_Order_Line"
            },
            "description": "Lines"
          },
          "shipping_service": {
            "type": "string",
            "description": "Shipping service code"
          },
          "shipping_service_label": {
            "type": "string",
            "description": "Shipping service"
          },
          "fill_or_kill": {
            "type": "integer",
            "enum": [
              0,
              1
            ],
            "description": "Fill or Kill"
          },
          "delivery_options_set": {
            "type": "integer",
            "enum": [
              0,
              1
            ],
            "description": "Delivery options chosen at the counter"
          },
          "delivery_signature": {
            "type": "integer",
            "enum": [
              0,
              1
            ],
            "description": "Signature"
          },
          "delivery_adult_signature": {
            "type": "integer",
            "enum": [
              0,
              1
            ],
            "description": "Adult signature"
          },
          "delivery_insurance": {
            "type": "integer",
            "enum": [
              0,
              1
            ],
            "description": "Insurance"
          },
          "source_doctype": {
            "type": "string",
            "description": "Source DocType (Link: DocType)"
          },
          "source_name": {
            "type": "string",
            "description": "Source Name (Link: source_doctype)"
          },
          "consumer_name": {
            "type": "string",
            "description": "Consumer / Store Name"
          },
          "contact_num": {
            "type": "string",
            "description": "Contact Number"
          },
          "ship_address_line1": {
            "type": "string",
            "description": "Ship Line 1"
          },
          "ship_address_line2": {
            "type": "string",
            "description": "Ship Line 2"
          },
          "ship_address_city": {
            "type": "string",
            "description": "Ship City"
          },
          "ship_address_state": {
            "type": "string",
            "description": "Ship State"
          },
          "ship_address_zip": {
            "type": "string",
            "description": "Ship ZIP"
          },
          "transfer_ffl_license": {
            "type": "string",
            "description": "Transfer FFL License"
          },
          "transfer_ffl_premise_street": {
            "type": "string",
            "description": "FFL Premise Street"
          },
          "transfer_ffl_premise_city": {
            "type": "string",
            "description": "FFL Premise City"
          },
          "transfer_ffl_premise_state": {
            "type": "string",
            "description": "FFL Premise State"
          },
          "transfer_ffl_premise_zip": {
            "type": "string",
            "description": "FFL Premise ZIP"
          },
          "transfer_ffl_record": {
            "type": "string",
            "description": "Transfer FFL Record (Link: ATF FFL Record)"
          },
          "placed_at": {
            "type": "string",
            "description": "Placed At"
          },
          "last_poll_at": {
            "type": "string",
            "description": "Last Poll At"
          },
          "next_poll_at": {
            "type": "string",
            "description": "Next Poll At"
          },
          "receive_status": {
            "type": "string",
            "enum": [
              "Not Received",
              "Partial",
              "Received"
            ],
            "description": "Receive Status"
          },
          "woo_notified_status": {
            "type": "string",
            "description": "Shop Notified Status"
          },
          "total_cost": {
            "type": "number",
            "description": "Total Cost"
          },
          "freight_cost": {
            "type": "number",
            "description": "Freight Cost"
          },
          "invoiced_freight": {
            "type": "number",
            "description": "Invoiced Freight"
          },
          "error": {
            "type": "string",
            "description": "Error"
          },
          "notes_posted": {
            "type": "string",
            "description": "Tracking Notes Posted"
          },
          "raw_request": {
            "type": "string",
            "description": "Raw Request"
          },
          "raw_response": {
            "type": "string",
            "description": "Raw Response"
          }
        },
        "required": [
          "distributor",
          "order_type",
          "account"
        ]
      },
      "Distributor_Order_Line": {
        "type": "object",
        "description": "Custom DocType (ffl_integrations); CRUD via /api/resource/Distributor%20Order%20Line — see docs/api/frappe-rest.md.",
        "properties": {
          "sku": {
            "type": "string",
            "description": "SKU"
          },
          "item_code": {
            "type": "string",
            "description": "Item (Link: Item)"
          },
          "description": {
            "type": "string",
            "description": "Description"
          },
          "wish_qty": {
            "type": "integer",
            "description": "Wish Qty"
          },
          "ack_qty": {
            "type": "integer",
            "description": "Ack Qty"
          },
          "unit_cost": {
            "type": "number",
            "description": "Unit Cost"
          },
          "case_note": {
            "type": "string",
            "description": "Case Price"
          },
          "invoiced_unit_cost": {
            "type": "number",
            "description": "Invoiced Unit Cost"
          },
          "ship_method": {
            "type": "string",
            "enum": [
              "Grnd",
              "2Day",
              "1Day",
              "Ndas",
              "Prio"
            ],
            "description": "Ship Method"
          },
          "item_status": {
            "type": "string",
            "description": "Item Status"
          },
          "invoiced_qty": {
            "type": "integer",
            "description": "Invoiced Qty"
          },
          "received_qty": {
            "type": "integer",
            "description": "Received Qty"
          },
          "substituted_qty": {
            "type": "integer",
            "description": "Substituted Qty"
          },
          "line_status": {
            "type": "string",
            "enum": [
              "Pending",
              "Acked",
              "Shipped",
              "Received",
              "Killed"
            ],
            "description": "Line Status"
          },
          "fulfillment": {
            "type": "string",
            "enum": [
              "local",
              "to_store",
              "fds",
              "direct"
            ],
            "description": "Fulfillment"
          },
          "invoices": {
            "type": "string",
            "description": "Invoices (CSV)"
          },
          "tracking_numbers": {
            "type": "string",
            "description": "Tracking Numbers (CSV)"
          },
          "serials": {
            "type": "string",
            "description": "Serials (CSV)"
          }
        },
        "required": [
          "sku"
        ]
      },
      "Dropship_Brand_Policy": {
        "type": "object",
        "description": "Custom DocType (ffl_integrations); CRUD via /api/resource/Dropship%20Brand%20Policy — see docs/api/frappe-rest.md.",
        "properties": {
          "brand": {
            "type": "string",
            "description": "Brand (Link: Brand)"
          },
          "distributor": {
            "type": "string",
            "description": "Distributor (Link: Distributor)"
          },
          "policy": {
            "type": "string",
            "enum": [
              "To Store",
              "Direct OK"
            ],
            "description": "Policy"
          },
          "reason": {
            "type": "string",
            "description": "Reason shown to staff"
          },
          "notes": {
            "type": "string",
            "description": "Notes"
          }
        },
        "required": [
          "brand",
          "policy"
        ]
      },
      "FastBound_Settings": {
        "type": "object",
        "description": "Custom DocType (ffl_integrations); CRUD via /api/resource/FastBound%20Settings — see docs/api/frappe-rest.md.",
        "properties": {
          "enabled": {
            "type": "integer",
            "enum": [
              0,
              1
            ],
            "description": "Enable FastBound"
          },
          "account_num": {
            "type": "string",
            "description": "Account number"
          },
          "api_key": {
            "type": "string",
            "description": "API key"
          },
          "base_url": {
            "type": "string",
            "description": "Base URL"
          },
          "default_audit_user": {
            "type": "string",
            "description": "Audit user"
          },
          "webhook_secret": {
            "type": "string",
            "description": "Webhook secret"
          },
          "last_import_at": {
            "type": "string",
            "description": "Last import"
          },
          "last_import_count": {
            "type": "integer",
            "description": "Items imported"
          },
          "last_import_errors": {
            "type": "string",
            "description": "Import errors"
          },
          "last_import_result": {
            "type": "string",
            "description": "Last import result"
          },
          "acquire_types": {
            "type": "string",
            "description": "Acquisition types"
          },
          "dispose_types": {
            "type": "string",
            "description": "Disposition types"
          },
          "smart_lists_synced_at": {
            "type": "string",
            "description": "Lists synced at"
          },
          "lookup_ffl_on_push": {
            "type": "integer",
            "enum": [
              0,
              1
            ],
            "description": "Look up FFL on push"
          },
          "request_timeout_seconds": {
            "type": "integer",
            "description": "Request Timeout (s)"
          }
        }
      },
      "GunBroker_Category_Map": {
        "type": "object",
        "description": "Custom DocType (ffl_integrations); CRUD via /api/resource/GunBroker%20Category%20Map — see docs/api/frappe-rest.md.",
        "properties": {
          "firearm_type": {
            "type": "string",
            "enum": [
              "Pistol",
              "Revolver",
              "Rifle",
              "Shotgun",
              "Receiver",
              "Other Firearm",
              "Silencer",
              "Short Barreled Rifle",
              "Short Barreled Shotgun",
              "Machine Gun",
              "Destructive Device",
              "Any Other Weapon"
            ],
            "description": "Firearm Type"
          },
          "item_group": {
            "type": "string",
            "description": "Item Group (Link: Item Group)"
          },
          "is_cr_eligible": {
            "type": "integer",
            "enum": [
              0,
              1
            ],
            "description": "C&R Eligible"
          },
          "is_antique": {
            "type": "integer",
            "enum": [
              0,
              1
            ],
            "description": "Antique"
          },
          "category_id": {
            "type": "integer",
            "description": "GunBroker Category ID"
          },
          "category_name": {
            "type": "string",
            "description": "Category Name"
          }
        },
        "required": [
          "category_id"
        ]
      },
      "GunBroker_Fee_Tier": {
        "type": "object",
        "description": "Custom DocType (ffl_integrations); CRUD via /api/resource/GunBroker%20Fee%20Tier — see docs/api/frappe-rest.md.",
        "properties": {
          "upper_bound": {
            "type": "number",
            "description": "Upper Bound"
          },
          "rate": {
            "type": "number",
            "description": "Fee Rate"
          }
        },
        "required": [
          "rate"
        ]
      },
      "GunBroker_Order": {
        "type": "object",
        "description": "Custom DocType (ffl_integrations); CRUD via /api/resource/GunBroker%20Order — see docs/api/frappe-rest.md.",
        "properties": {
          "gb_order_id": {
            "type": "string",
            "description": "GunBroker Order ID"
          },
          "order_status": {
            "type": "string",
            "enum": [
              "Pending Fulfillment",
              "Transferred",
              "Cancelled"
            ],
            "description": "Status"
          },
          "order_date": {
            "type": "string",
            "description": "Order Date"
          },
          "gb_status": {
            "type": "integer",
            "description": "GunBroker Status Code"
          },
          "gb_status_label": {
            "type": "string",
            "description": "GunBroker Status"
          },
          "gb_last_modified": {
            "type": "string",
            "description": "GunBroker Last Modified"
          },
          "acknowledged_at": {
            "type": "string",
            "description": "Acknowledged At"
          },
          "buyer_user_id": {
            "type": "string",
            "description": "Buyer User ID"
          },
          "buyer_username": {
            "type": "string",
            "description": "Buyer Username"
          },
          "customer": {
            "type": "string",
            "description": "Customer (Link: Customer)"
          },
          "customer_name": {
            "type": "string",
            "description": "Bill To Name"
          },
          "customer_email": {
            "type": "string",
            "description": "Bill To Email"
          },
          "customer_phone": {
            "type": "string",
            "description": "Bill To Phone"
          },
          "tax_exempt": {
            "type": "integer",
            "enum": [
              0,
              1
            ],
            "description": "Tax Exempt"
          },
          "lines": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/GunBroker_Order_Line"
            },
            "description": "Lines"
          },
          "serials": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/GunBroker_Order_Serial"
            },
            "description": "Serials"
          },
          "ship_to_name": {
            "type": "string",
            "description": "Name"
          },
          "ship_to_line1": {
            "type": "string",
            "description": "Address 1"
          },
          "ship_to_line2": {
            "type": "string",
            "description": "Address 2"
          },
          "ship_to_city": {
            "type": "string",
            "description": "City"
          },
          "ship_to_state": {
            "type": "string",
            "description": "State"
          },
          "ship_to_zip": {
            "type": "string",
            "description": "ZIP"
          },
          "ffl_number": {
            "type": "string",
            "description": "FFL Number"
          },
          "atf_ffl_record": {
            "type": "string",
            "description": "ATF FFL Record (Link: ATF FFL Record)"
          },
          "is_cr_transfer": {
            "type": "integer",
            "enum": [
              0,
              1
            ],
            "description": "C&R (Type 03) Transfer"
          },
          "ships_direct": {
            "type": "integer",
            "enum": [
              0,
              1
            ],
            "description": "Ships Direct to Buyer (antique)"
          },
          "ffl_received": {
            "type": "integer",
            "enum": [
              0,
              1
            ],
            "description": "FFL Received"
          },
          "ffl_received_at": {
            "type": "string",
            "description": "FFL Received At"
          },
          "ffl_status": {
            "type": "string",
            "description": "FFL Status"
          },
          "effl_url": {
            "type": "string",
            "description": "eFFL URL"
          },
          "seller_packet_url": {
            "type": "string",
            "description": "Seller Packet URL"
          },
          "cr_contact_name": {
            "type": "string",
            "description": "Collector Name (as printed on license)"
          },
          "cr_license_expiry": {
            "type": "string",
            "description": "C&R License Expiration"
          },
          "cr_premise_street": {
            "type": "string",
            "description": "Licensed Premises — Address 1"
          },
          "cr_premise_street2": {
            "type": "string",
            "description": "Address 2"
          },
          "cr_premise_city": {
            "type": "string",
            "description": "City"
          },
          "cr_premise_state": {
            "type": "string",
            "description": "State"
          },
          "cr_premise_zip": {
            "type": "string",
            "description": "ZIP"
          },
          "cr_verified_by": {
            "type": "string",
            "description": "Verified By (Link: User)"
          },
          "cr_verified_at": {
            "type": "string",
            "description": "Verified At"
          },
          "payment_received": {
            "type": "integer",
            "enum": [
              0,
              1
            ],
            "description": "Payment Received (GunBroker flag)"
          },
          "payment_received_at": {
            "type": "string",
            "description": "Payment Received At (GunBroker)"
          },
          "payment_methods": {
            "type": "string",
            "description": "Payment Methods Offered"
          },
          "payment_source": {
            "type": "string",
            "enum": [
              "Gateway (Immediate Checkout)",
              "Check or Money Order",
              "Gateway (GB-set)",
              "Paid to Store",
              "Unknown"
            ],
            "description": "Payment Source"
          },
          "payment_mode_used": {
            "type": "string",
            "description": "Mode of Payment Recorded"
          },
          "payment_reference_no": {
            "type": "string",
            "description": "Payment Reference / Cheque No"
          },
          "payment_amount": {
            "type": "number",
            "description": "Amount Received"
          },
          "payment_received_on": {
            "type": "string",
            "description": "Deposited On"
          },
          "payment_entry": {
            "type": "string",
            "description": "Payment Entry (Link: Payment Entry)"
          },
          "gb_overpayment_pe": {
            "type": "string",
            "description": "Overpayment Entry (Link: Payment Entry)"
          },
          "payment_log_amount": {
            "type": "number",
            "description": "Payment Log Amount"
          },
          "payment_log_transaction_id": {
            "type": "string",
            "description": "Payment Log Transaction ID"
          },
          "payment_log_date": {
            "type": "string",
            "description": "Payment Log Date"
          },
          "payment_log_cleared": {
            "type": "integer",
            "enum": [
              0,
              1
            ],
            "description": "Payment Log Cleared"
          },
          "currency": {
            "type": "string",
            "description": "Currency"
          },
          "order_total": {
            "type": "number",
            "description": "Order Total"
          },
          "item_subtotal": {
            "type": "number",
            "description": "Item Subtotal"
          },
          "ship_cost": {
            "type": "number",
            "description": "Shipping"
          },
          "ship_handling_cost": {
            "type": "number",
            "description": "Handling"
          },
          "ship_insurance_cost": {
            "type": "number",
            "description": "Insurance"
          },
          "sales_tax_total": {
            "type": "number",
            "description": "Sales Tax Total (incl. service fee)"
          },
          "compliance_fee": {
            "type": "number",
            "description": "Marketplace Service Fee"
          },
          "buyers_premium": {
            "type": "number",
            "description": "Buyer's Premium"
          },
          "coupon_value": {
            "type": "number",
            "description": "Coupon Value"
          },
          "lost_cash_discount": {
            "type": "number",
            "description": "Lost Cash Discount"
          },
          "misc_charge": {
            "type": "number",
            "description": "Misc Charge"
          },
          "misc_fee": {
            "type": "number",
            "description": "Misc Fee"
          },
          "sales_invoice": {
            "type": "string",
            "description": "Sales Invoice (Link: Sales Invoice)"
          },
          "fee_accrual_je": {
            "type": "string",
            "description": "Fee Accrual Journal Entry (Link: Journal Entry)"
          },
          "ship_carrier": {
            "type": "string",
            "enum": [
              "Unknown",
              "FedEx",
              "UPS",
              "USPS"
            ],
            "description": "Carrier"
          },
          "tracking_number": {
            "type": "string",
            "description": "Tracking Number"
          },
          "shipstation_order_id": {
            "type": "string",
            "description": "ShipStation Shipment ID"
          },
          "shipstation_status": {
            "type": "string",
            "description": "ShipStation Status"
          },
          "shipping_flag_pushed_at": {
            "type": "string",
            "description": "OrderShipped Flag Sent At"
          },
          "tracking_pushed_at": {
            "type": "string",
            "description": "Tracking Sent At"
          },
          "gb_ship_writeback_pending": {
            "type": "integer",
            "enum": [
              0,
              1
            ],
            "description": "Ship Write-back Pending"
          },
          "cancel_date": {
            "type": "string",
            "description": "Cancelled At"
          },
          "refund_date": {
            "type": "string",
            "description": "Refunded At"
          },
          "returned_date": {
            "type": "string",
            "description": "Returned At"
          },
          "is_chargeback": {
            "type": "integer",
            "enum": [
              0,
              1
            ],
            "description": "Chargeback"
          },
          "chargeback_handled_at": {
            "type": "string",
            "description": "Chargeback Handled At"
          },
          "refund_handled_at": {
            "type": "string",
            "description": "Refund Handled At"
          },
          "sync_error": {
            "type": "string",
            "description": "Last Sync Error"
          },
          "sync_fail_count": {
            "type": "integer",
            "description": "Consecutive Sync Failures"
          },
          "raw_payload": {
            "type": "string",
            "description": "Raw GunBroker Payload"
          }
        },
        "required": [
          "gb_order_id",
          "order_status"
        ]
      },
      "GunBroker_Order_Line": {
        "type": "object",
        "description": "Custom DocType (ffl_integrations); CRUD via /api/resource/GunBroker%20Order%20Line — see docs/api/frappe-rest.md.",
        "properties": {
          "item_code": {
            "type": "string",
            "description": "Item (Link: Item)"
          },
          "title": {
            "type": "string",
            "description": "Listing Title"
          },
          "qty": {
            "type": "integer",
            "description": "Qty"
          },
          "unit_price": {
            "type": "number",
            "description": "Unit Price"
          },
          "sku": {
            "type": "string",
            "description": "SKU"
          },
          "gb_item_id": {
            "type": "string",
            "description": "GunBroker Item ID"
          },
          "serial_number": {
            "type": "string",
            "description": "Serial Number"
          },
          "subtotal": {
            "type": "number",
            "description": "Line Subtotal"
          },
          "line_tax": {
            "type": "number",
            "description": "Line Sales Tax"
          },
          "is_ffl_required": {
            "type": "integer",
            "enum": [
              0,
              1
            ],
            "description": "FFL Required"
          },
          "fvf_amount": {
            "type": "number",
            "description": "Final Value Fee"
          },
          "ffl_doc_fee_amount": {
            "type": "number",
            "description": "FFL Document Fee"
          },
          "reservation_error": {
            "type": "string",
            "description": "Reservation Error"
          }
        }
      },
      "GunBroker_Order_Serial": {
        "type": "object",
        "description": "Custom DocType (ffl_integrations); CRUD via /api/resource/GunBroker%20Order%20Serial — see docs/api/frappe-rest.md.",
        "properties": {
          "item_code": {
            "type": "string",
            "description": "Item (Link: Item)"
          },
          "confirmed_serial": {
            "type": "string",
            "description": "Confirmed Serial"
          },
          "unit_index": {
            "type": "integer",
            "description": "Unit #"
          },
          "gb_item_id": {
            "type": "string",
            "description": "GunBroker Item ID"
          },
          "is_model_unit": {
            "type": "integer",
            "enum": [
              0,
              1
            ],
            "description": "Model Unit"
          },
          "assigned_by": {
            "type": "string",
            "description": "Assigned By (Link: User)"
          },
          "assigned_at": {
            "type": "string",
            "description": "Assigned At"
          },
          "refunded_on_gb": {
            "type": "integer",
            "enum": [
              0,
              1
            ],
            "description": "Refunded on GunBroker"
          },
          "reservation_error": {
            "type": "string",
            "description": "Reservation Error"
          }
        }
      },
      "GunBroker_Settings": {
        "type": "object",
        "description": "Custom DocType (ffl_integrations); CRUD via /api/resource/GunBroker%20Settings — see docs/api/frappe-rest.md.",
        "properties": {
          "enabled": {
            "type": "integer",
            "enum": [
              0,
              1
            ],
            "description": "Enable GunBroker"
          },
          "sandbox_mode": {
            "type": "integer",
            "enum": [
              0,
              1
            ],
            "description": "Sandbox mode"
          },
          "username": {
            "type": "string",
            "description": "Seller username"
          },
          "password": {
            "type": "string",
            "description": "Seller password"
          },
          "last_listing_push_at": {
            "type": "string",
            "description": "Last listing push"
          },
          "last_listing_push_count": {
            "type": "integer",
            "description": "Listings pushed"
          },
          "last_sweep_at": {
            "type": "string",
            "description": "Last sweep"
          },
          "last_orders_synced_at": {
            "type": "string",
            "description": "Orders synced up to (UTC)"
          },
          "last_order_sync_count": {
            "type": "integer",
            "description": "Orders synced"
          },
          "last_sync_error": {
            "type": "string",
            "description": "Last error"
          },
          "postal_code": {
            "type": "string",
            "description": "Ship-from ZIP"
          },
          "country_code": {
            "type": "string",
            "description": "Country"
          },
          "listing_duration": {
            "type": "string",
            "enum": [
              "30",
              "60",
              "90"
            ],
            "description": "Duration (days, fixed price)"
          },
          "auto_relist": {
            "type": "string",
            "enum": [
              "1 Do Not Relist",
              "4 Relist Fixed Price"
            ],
            "description": "Auto-relist (fixed price)"
          },
          "inspection_period": {
            "type": "string",
            "enum": [
              "1 AS IS",
              "4 3 days",
              "12 30-day"
            ],
            "description": "Inspection period"
          },
          "is_ffl_required": {
            "type": "integer",
            "enum": [
              0,
              1
            ],
            "description": "FFL required"
          },
          "will_ship_international": {
            "type": "integer",
            "enum": [
              0,
              1
            ],
            "description": "Ships internationally"
          },
          "max_pictures": {
            "type": "integer",
            "description": "Photos per listing"
          },
          "use_default_exclude_states": {
            "type": "integer",
            "enum": [
              0,
              1
            ],
            "description": "Use account's excluded states"
          },
          "exclude_states": {
            "type": "string",
            "description": "Excluded states"
          },
          "default_listing_type": {
            "type": "string",
            "enum": [
              "Fixed Price",
              "Auction"
            ],
            "description": "Listing type offered"
          },
          "auction_duration": {
            "type": "string",
            "enum": [
              "1",
              "3",
              "5",
              "7",
              "10",
              "14"
            ],
            "description": "Auction length (days)"
          },
          "auction_auto_relist": {
            "type": "string",
            "enum": [
              "2 Relist Until Sold",
              "1 Do Not Relist"
            ],
            "description": "Auto-relist (auction)"
          },
          "who_pays_shipping": {
            "type": "string",
            "enum": [
              "2 Seller pays",
              "4 Buyer pays actual",
              "8 Buyer pays fixed"
            ],
            "description": "Shipping paid by"
          },
          "long_gun_ship_cost": {
            "type": "number",
            "description": "Long gun rate (default)"
          },
          "handgun_ship_cost": {
            "type": "number",
            "description": "Handgun rate (default)"
          },
          "accessory_ship_cost": {
            "type": "number",
            "description": "Accessory / ammo rate (default)"
          },
          "pay_certified_check": {
            "type": "integer",
            "enum": [
              0,
              1
            ],
            "description": "Certified check"
          },
          "pay_usps_money_order": {
            "type": "integer",
            "enum": [
              0,
              1
            ],
            "description": "USPS money order"
          },
          "pay_money_order": {
            "type": "integer",
            "enum": [
              0,
              1
            ],
            "description": "Money order"
          },
          "pay_personal_check": {
            "type": "integer",
            "enum": [
              0,
              1
            ],
            "description": "Personal check"
          },
          "pay_cod": {
            "type": "integer",
            "enum": [
              0,
              1
            ],
            "description": "COD"
          },
          "card_checkout_enabled": {
            "type": "integer",
            "enum": [
              0,
              1
            ],
            "description": "Accept cards"
          },
          "pay_visa_mastercard": {
            "type": "integer",
            "enum": [
              0,
              1
            ],
            "description": "Visa / MasterCard"
          },
          "pay_amex": {
            "type": "integer",
            "enum": [
              0,
              1
            ],
            "description": "American Express"
          },
          "pay_discover": {
            "type": "integer",
            "enum": [
              0,
              1
            ],
            "description": "Discover"
          },
          "category_map": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/GunBroker_Category_Map"
            },
            "description": "Category map"
          },
          "title_banned_phrases": {
            "type": "string",
            "description": "Blocked title phrases"
          },
          "description_footer": {
            "type": "string",
            "description": "Description footer"
          },
          "watermark_image": {
            "type": "string",
            "description": "Logo"
          },
          "watermark_text": {
            "type": "string",
            "description": "Text under the logo"
          },
          "check_deposit_account": {
            "type": "string",
            "description": "Check deposit account (Link: Account)"
          },
          "card_clearing_account": {
            "type": "string",
            "description": "Card clearing account (Link: Account)"
          },
          "ffl_doc_fee": {
            "type": "number",
            "description": "FFL doc fee (per item)"
          },
          "fee_tiers": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/GunBroker_Fee_Tier"
            },
            "description": "Final value fee tiers"
          },
          "auto_sync_enabled": {
            "type": "integer",
            "enum": [
              0,
              1
            ],
            "description": "Scheduled sync"
          },
          "auto_acknowledge": {
            "type": "integer",
            "enum": [
              0,
              1
            ],
            "description": "Auto-acknowledge orders"
          },
          "stale_paid_days": {
            "type": "integer",
            "description": "Paid-not-shipped alert (days)"
          },
          "end_strategy": {
            "type": "string",
            "enum": [
              "Delete Endpoint",
              "Manual Only"
            ],
            "description": "End listings via"
          },
          "orders_since_override": {
            "type": "string",
            "description": "Re-read orders since"
          },
          "request_timeout_seconds": {
            "type": "integer",
            "description": "Request timeout (s)"
          },
          "probe_timeout_seconds": {
            "type": "integer",
            "description": "Counter check budget (s)"
          },
          "page_size": {
            "type": "integer",
            "description": "API page size"
          },
          "base_url_override": {
            "type": "string",
            "description": "Base URL override"
          },
          "webhook_username": {
            "type": "string",
            "description": "Webhook user name"
          },
          "webhook_password": {
            "type": "string",
            "description": "Webhook password"
          },
          "last_webhook_at": {
            "type": "string",
            "description": "Last webhook received"
          },
          "last_webhook_event": {
            "type": "string",
            "description": "Last webhook event"
          },
          "order_sync_nudge": {
            "type": "string",
            "description": "Order sync nudge"
          }
        }
      },
      "Lipseys_Settings": {
        "type": "object",
        "description": "Custom DocType (ffl_integrations); CRUD via /api/resource/Lipseys%20Settings — see docs/api/frappe-rest.md.",
        "properties": {
          "ordering_enabled": {
            "type": "integer",
            "enum": [
              0,
              1
            ],
            "description": "Allow live orders"
          },
          "customer_number": {
            "type": "string",
            "description": "Customer number"
          },
          "dealer_email": {
            "type": "string",
            "description": "Email"
          },
          "dealer_password": {
            "type": "string",
            "description": "Password"
          },
          "dropship_email": {
            "type": "string",
            "description": "Email"
          },
          "dropship_password": {
            "type": "string",
            "description": "Password"
          },
          "base_url": {
            "type": "string",
            "description": "API base URL"
          },
          "disable_email": {
            "type": "integer",
            "enum": [
              0,
              1
            ],
            "description": "No confirmation email from Lipsey's"
          },
          "dropship_overnight": {
            "type": "integer",
            "enum": [
              0,
              1
            ],
            "description": "Accessory drop-ship orders ship overnight"
          },
          "rate_dropship_firearm": {
            "type": "number",
            "description": "Drop-ship firearm order"
          },
          "rate_dropship_accessory": {
            "type": "number",
            "description": "Drop-ship accessory order"
          },
          "shipping_polled_through": {
            "type": "string",
            "description": "Shipping polled through (dealer)"
          },
          "dropship_shipping_polled_through": {
            "type": "string",
            "description": "Shipping polled through (drop-ship)"
          },
          "last_shipping_poll_at": {
            "type": "string",
            "description": "Last shipping poll"
          },
          "last_error": {
            "type": "string",
            "description": "Last error"
          }
        }
      },
      "Payroc_Settings": {
        "type": "object",
        "description": "Custom DocType (ffl_integrations); CRUD via /api/resource/Payroc%20Settings — see docs/api/frappe-rest.md.",
        "properties": {
          "enabled": {
            "type": "integer",
            "enum": [
              0,
              1
            ],
            "description": "Enable Payroc Terminal Integration"
          },
          "require_card_reference": {
            "type": "integer",
            "enum": [
              0,
              1
            ],
            "description": "Require Card Reference (manual terminal)"
          },
          "api_key": {
            "type": "string",
            "description": "Merchant API Key"
          },
          "default_currency": {
            "type": "string",
            "description": "Default Currency (Link: Currency)"
          },
          "default_terminal": {
            "type": "string",
            "description": "Gateway Terminal Number"
          },
          "device_serial_number": {
            "type": "string",
            "description": "Device Serial Number"
          },
          "saved_card_terminal": {
            "type": "string",
            "description": "Saved-Card Terminal Number"
          },
          "payment_page_secret": {
            "type": "string",
            "description": "Payment Page Secret"
          },
          "sandbox_mode": {
            "type": "integer",
            "enum": [
              0,
              1
            ],
            "description": "Sandbox Mode"
          },
          "card_readers": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Card_Reader"
            },
            "description": "Card Readers"
          },
          "last_token_refreshed_at": {
            "type": "string",
            "description": "Last Token Refreshed At"
          },
          "last_charge_at": {
            "type": "string",
            "description": "Last Charge At"
          },
          "integration_id": {
            "type": "string",
            "description": "X-Integration-ID (ISV only)"
          },
          "base_url_override": {
            "type": "string",
            "description": "Base URL Override"
          },
          "request_timeout_seconds": {
            "type": "integer",
            "description": "Request Timeout (seconds)"
          }
        }
      },
      "RSR_Catalog_Item": {
        "type": "object",
        "description": "Custom DocType (ffl_integrations); CRUD via /api/resource/RSR%20Catalog%20Item — see docs/api/frappe-rest.md.",
        "properties": {
          "rsr_stock_number": {
            "type": "string",
            "description": "RSR Stock #"
          },
          "upc": {
            "type": "string",
            "description": "UPC"
          },
          "mfg_number": {
            "type": "string",
            "description": "Mfg Part #"
          },
          "department_number": {
            "type": "string",
            "description": "Department #"
          },
          "manufacturer": {
            "type": "string",
            "description": "Manufacturer"
          },
          "model": {
            "type": "string",
            "description": "Model"
          },
          "caliber": {
            "type": "string",
            "description": "Caliber"
          },
          "short_description": {
            "type": "string",
            "description": "Short Description"
          },
          "long_description": {
            "type": "string",
            "description": "Long Description"
          },
          "msrp": {
            "type": "number",
            "description": "MSRP"
          },
          "dealer_price": {
            "type": "number",
            "description": "Dealer Price"
          },
          "map_price": {
            "type": "number",
            "description": "MAP"
          },
          "weight_lb": {
            "type": "number",
            "description": "Weight (lb)"
          },
          "quantity": {
            "type": "integer",
            "description": "Quantity at RSR"
          },
          "status_flag": {
            "type": "string",
            "enum": [
              "Allocated",
              "Closeout",
              "Deleted"
            ],
            "description": "Status"
          },
          "discontinued": {
            "type": "integer",
            "enum": [
              0,
              1
            ],
            "description": "Discontinued"
          },
          "ffl_required": {
            "type": "integer",
            "enum": [
              0,
              1
            ],
            "description": "FFL Required"
          },
          "ships_ground_only": {
            "type": "integer",
            "enum": [
              0,
              1
            ],
            "description": "Ships Ground Only"
          },
          "signature_required": {
            "type": "integer",
            "enum": [
              0,
              1
            ],
            "description": "Adult Signature Required"
          },
          "dropship_blocked": {
            "type": "integer",
            "enum": [
              0,
              1
            ],
            "description": "Blocked from Drop Ship"
          },
          "vendor_approval_required": {
            "type": "integer",
            "enum": [
              0,
              1
            ],
            "description": "Vendor Approval Required"
          },
          "prop65": {
            "type": "integer",
            "enum": [
              0,
              1
            ],
            "description": "CA Prop 65"
          },
          "image_name": {
            "type": "string",
            "description": "Image Filename"
          },
          "image_url": {
            "type": "string",
            "description": "Image URL"
          },
          "image_url_hires": {
            "type": "string",
            "description": "Hi-Res Image URL"
          },
          "loaded_at": {
            "type": "string",
            "description": "Last Catalog Load"
          },
          "last_quantity_at": {
            "type": "string",
            "description": "Last Quantity Update"
          }
        },
        "required": [
          "rsr_stock_number"
        ]
      },
      "RSR_Department": {
        "type": "object",
        "description": "Custom DocType (ffl_integrations); CRUD via /api/resource/RSR%20Department — see docs/api/frappe-rest.md.",
        "properties": {
          "department_number": {
            "type": "string",
            "description": "Department #"
          },
          "department_name": {
            "type": "string",
            "description": "Department Name"
          },
          "ffl_required": {
            "type": "integer",
            "enum": [
              0,
              1
            ],
            "description": "FFL Required"
          },
          "default_item_group": {
            "type": "string",
            "description": "Default Item Group (Link: Item Group)"
          }
        },
        "required": [
          "department_number",
          "department_name"
        ]
      },
      "RSR_Settings": {
        "type": "object",
        "description": "Custom DocType (ffl_integrations); CRUD via /api/resource/RSR%20Settings — see docs/api/frappe-rest.md.",
        "properties": {
          "api_enabled": {
            "type": "integer",
            "enum": [
              0,
              1
            ],
            "description": "Allow live orders"
          },
          "dealer_account": {
            "type": "string",
            "description": "Dealer account #"
          },
          "dealer_password": {
            "type": "string",
            "description": "Dealer API password"
          },
          "fulfillment_account": {
            "type": "string",
            "description": "Fulfillment account #"
          },
          "fulfillment_password": {
            "type": "string",
            "description": "Fulfillment API password"
          },
          "ftp_host": {
            "type": "string",
            "description": "FTP host"
          },
          "ftp_port": {
            "type": "integer",
            "description": "FTP port"
          },
          "key_dealer": {
            "type": "integer",
            "enum": [
              0,
              1
            ],
            "description": "Key dealer feed"
          },
          "ftp_username": {
            "type": "string",
            "description": "FTP username"
          },
          "ftp_password": {
            "type": "string",
            "description": "FTP password"
          },
          "ftps_skip_verify": {
            "type": "integer",
            "enum": [
              0,
              1
            ],
            "description": "Skip TLS certificate check (not recommended)"
          },
          "api_base_url": {
            "type": "string",
            "description": "API base URL"
          },
          "pos_indicator": {
            "type": "string",
            "description": "POS indicator"
          },
          "order_email": {
            "type": "string",
            "description": "Order email"
          },
          "hold_escalate_days": {
            "type": "integer",
            "description": "Flag a hold after (days)"
          },
          "store_free_freight": {
            "type": "integer",
            "enum": [
              0,
              1
            ],
            "description": "Free freight on ship-to-store orders"
          },
          "free_freight_threshold": {
            "type": "number",
            "description": "Store orders ship free above"
          },
          "rate_ground": {
            "type": "number",
            "description": "Ground"
          },
          "rate_2day": {
            "type": "number",
            "description": "2Day (handguns)"
          },
          "fee_signature": {
            "type": "number",
            "description": "Adult signature (firearm orders)"
          },
          "freight_variance_alert": {
            "type": "number",
            "description": "Alert when invoiced freight differs by more than"
          }
        }
      },
      "RSR_Ship_Restriction": {
        "type": "object",
        "description": "Custom DocType (ffl_integrations); CRUD via /api/resource/RSR%20Ship%20Restriction — see docs/api/frappe-rest.md.",
        "properties": {
          "rsr_stock_number": {
            "type": "string",
            "description": "RSR Stock #"
          },
          "entry_count": {
            "type": "integer",
            "description": "Entry Count"
          },
          "load_batch": {
            "type": "string",
            "description": "Load Batch"
          },
          "entries": {
            "type": "string",
            "description": "Entries (JSON)"
          }
        },
        "required": [
          "rsr_stock_number"
        ]
      },
      "Saved_Card": {
        "type": "object",
        "description": "Custom DocType (ffl_integrations); CRUD via /api/resource/Saved%20Card — see docs/api/frappe-rest.md.",
        "properties": {
          "customer": {
            "type": "string",
            "description": "Customer (Link: Customer)"
          },
          "card_summary": {
            "type": "string",
            "description": "Card"
          },
          "card_expiry": {
            "type": "string",
            "description": "Expiry (MMYY)"
          },
          "status": {
            "type": "string",
            "enum": [
              "Active",
              "Removed"
            ],
            "description": "Status"
          },
          "is_default": {
            "type": "integer",
            "enum": [
              0,
              1
            ],
            "description": "Default Card"
          },
          "usage": {
            "type": "string",
            "enum": [
              "UNSCHEDULED",
              "RECURRING"
            ],
            "description": "Usage"
          },
          "authorization": {
            "type": "string",
            "description": "Signed Authorization (Link: Customer Agreement)"
          },
          "source_doctype": {
            "type": "string",
            "description": "Saved From (Type) (Link: DocType)"
          },
          "source_name": {
            "type": "string",
            "description": "Saved From (Link: source_doctype)"
          },
          "processor": {
            "type": "string",
            "description": "Processor"
          },
          "initial_reference": {
            "type": "string",
            "description": "First Charge Reference"
          },
          "merchant_reference": {
            "type": "string",
            "description": "Merchant Reference"
          },
          "token": {
            "type": "string",
            "description": "Gateway Token"
          },
          "removed_by": {
            "type": "string",
            "description": "Removed By (Link: User)"
          },
          "removed_on": {
            "type": "string",
            "description": "Removed On"
          },
          "removed_reason": {
            "type": "string",
            "description": "Reason"
          }
        },
        "required": [
          "customer",
          "authorization",
          "processor",
          "token"
        ]
      },
      "ShipStation_Settings": {
        "type": "object",
        "description": "Custom DocType (ffl_integrations); CRUD via /api/resource/ShipStation%20Settings — see docs/api/frappe-rest.md.",
        "properties": {
          "enabled": {
            "type": "integer",
            "enum": [
              0,
              1
            ],
            "description": "Enabled"
          },
          "api_key": {
            "type": "string",
            "description": "API Key"
          },
          "sandbox_mode": {
            "type": "integer",
            "enum": [
              0,
              1
            ],
            "description": "Sandbox Mode"
          },
          "store_id": {
            "type": "string",
            "description": "Store ID"
          },
          "ship_from_warehouse_id": {
            "type": "string",
            "description": "Ship-From Warehouse ID"
          },
          "default_parcel_weight_oz": {
            "type": "number",
            "description": "Default Parcel Weight (oz)"
          },
          "base_url_override": {
            "type": "string",
            "description": "Base URL Override"
          },
          "request_timeout_seconds": {
            "type": "integer",
            "description": "Request Timeout (s)"
          }
        }
      },
      "Sports_South_Settings": {
        "type": "object",
        "description": "Custom DocType (ffl_integrations); CRUD via /api/resource/Sports%20South%20Settings — see docs/api/frappe-rest.md.",
        "properties": {
          "ordering_enabled": {
            "type": "integer",
            "enum": [
              0,
              1
            ],
            "description": "Allow live orders"
          },
          "sandbox_mode": {
            "type": "integer",
            "enum": [
              0,
              1
            ],
            "description": "Sandbox mode"
          },
          "customer_number": {
            "type": "string",
            "description": "Account number"
          },
          "username": {
            "type": "string",
            "description": "API user name"
          },
          "password": {
            "type": "string",
            "description": "API password"
          },
          "base_url": {
            "type": "string",
            "description": "API base URL"
          },
          "auto_email_ffl": {
            "type": "integer",
            "enum": [
              0,
              1
            ],
            "description": "Email the transfer FFL automatically"
          },
          "fulfillment_email": {
            "type": "string",
            "description": "Sports South fulfillment email"
          },
          "order_email_cc": {
            "type": "string",
            "description": "CC on FFL emails"
          },
          "sales_message": {
            "type": "string",
            "description": "Sales message on every order"
          },
          "ship_via_ground": {
            "type": "string",
            "description": "Ground ship code"
          },
          "ship_via_2day": {
            "type": "string",
            "description": "2-Day Air ship code"
          },
          "accessory_ground_economy": {
            "type": "integer",
            "enum": [
              0,
              1
            ],
            "description": "Accessory / ammunition orders ship Ground Economy"
          },
          "firearm_signature": {
            "type": "integer",
            "enum": [
              0,
              1
            ],
            "description": "Signature"
          },
          "firearm_adult_signature": {
            "type": "integer",
            "enum": [
              0,
              1
            ],
            "description": "Adult signature"
          },
          "firearm_insurance": {
            "type": "integer",
            "enum": [
              0,
              1
            ],
            "description": "Insurance"
          },
          "other_signature": {
            "type": "integer",
            "enum": [
              0,
              1
            ],
            "description": "Signature"
          },
          "other_adult_signature": {
            "type": "integer",
            "enum": [
              0,
              1
            ],
            "description": "Adult signature"
          },
          "other_insurance": {
            "type": "integer",
            "enum": [
              0,
              1
            ],
            "description": "Insurance"
          },
          "price_drift_alert_pct": {
            "type": "number",
            "description": "Alert when the filled price exceeds the quote by"
          },
          "hold_escalate_days": {
            "type": "integer",
            "description": "Flag a hold after (days)"
          },
          "store_ship_name": {
            "type": "string",
            "description": "Name"
          },
          "store_ship_attn": {
            "type": "string",
            "description": "Attention"
          },
          "store_ship_line1": {
            "type": "string",
            "description": "Address line 1"
          },
          "store_ship_line2": {
            "type": "string",
            "description": "Address line 2"
          },
          "store_ship_city": {
            "type": "string",
            "description": "City"
          },
          "store_ship_state": {
            "type": "string",
            "description": "State"
          },
          "store_ship_zip": {
            "type": "string",
            "description": "ZIP"
          },
          "store_ship_phone": {
            "type": "string",
            "description": "Phone"
          },
          "rate_handgun_2day": {
            "type": "number",
            "description": "Handgun, 2-Day Air"
          },
          "rate_long_gun_ground": {
            "type": "number",
            "description": "Long gun, Ground Premium"
          },
          "rate_accessory_ground": {
            "type": "number",
            "description": "Accessory / ammunition, Ground Premium"
          },
          "rate_accessory_economy": {
            "type": "number",
            "description": "Accessory / ammunition, Ground Economy"
          },
          "rate_2day_air": {
            "type": "number",
            "description": "2-Day Air (long gun / accessory)"
          },
          "rate_next_day": {
            "type": "number",
            "description": "Next-Day Air"
          },
          "fee_signature": {
            "type": "number",
            "description": "Signature"
          },
          "fee_adult_signature": {
            "type": "number",
            "description": "Adult signature"
          },
          "fee_insurance_pct": {
            "type": "number",
            "description": "Insurance, % of order"
          },
          "fee_insurance_min": {
            "type": "number",
            "description": "Insurance minimum"
          },
          "store_free_handgun_qty": {
            "type": "integer",
            "description": "Handguns ship free from (count)"
          },
          "store_free_handgun_amount": {
            "type": "number",
            "description": "Handguns ship free from (value)"
          },
          "store_free_other_amount": {
            "type": "number",
            "description": "Long guns / ammo / accessories ship free from"
          },
          "store_other_rate": {
            "type": "number",
            "description": "Long guns / ammo / accessories below that"
          },
          "freight_variance_alert": {
            "type": "number",
            "description": "Alert when invoiced freight differs by more than"
          },
          "credits_polled_through": {
            "type": "string",
            "description": "Credits polled through"
          },
          "last_credits_poll_at": {
            "type": "string",
            "description": "Last credit poll"
          },
          "last_error": {
            "type": "string",
            "description": "Last error"
          }
        }
      },
      "Woo_Online_Order": {
        "type": "object",
        "description": "Custom DocType (ffl_woo_sync); CRUD via /api/resource/Woo%20Online%20Order — see docs/api/frappe-rest.md.",
        "properties": {
          "woo_order_id": {
            "type": "string",
            "description": "Woo Order ID"
          },
          "order_status": {
            "type": "string",
            "enum": [
              "Pending Fulfillment",
              "Transferred",
              "Cancelled"
            ],
            "description": "Fulfillment Status"
          },
          "woo_status": {
            "type": "string",
            "description": "WooCommerce Status"
          },
          "site": {
            "type": "string",
            "enum": [
              "retail"
            ],
            "description": "Site"
          },
          "dropship_status": {
            "type": "string",
            "enum": [
              "Pending Route",
              "Ordered",
              "Complete",
              "Error"
            ],
            "description": "Drop-ship Status"
          },
          "transferred_at": {
            "type": "string",
            "description": "Transferred At"
          },
          "paid_at": {
            "type": "string",
            "description": "Paid At"
          },
          "customer_name": {
            "type": "string",
            "description": "Customer Name"
          },
          "customer_phone": {
            "type": "string",
            "description": "Phone"
          },
          "customer_email": {
            "type": "string",
            "description": "Email"
          },
          "customer": {
            "type": "string",
            "description": "POS Customer (Link: Customer)"
          },
          "lines": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Woo_Online_Order_Line"
            },
            "description": "Lines"
          },
          "serials": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Woo_Online_Order_Serial"
            },
            "description": "Firearm Serials"
          },
          "currency": {
            "type": "string",
            "description": "Currency"
          },
          "order_total": {
            "type": "number",
            "description": "Order Total"
          },
          "total_tax": {
            "type": "number",
            "description": "Total Tax"
          },
          "shipping_total": {
            "type": "number",
            "description": "Shipping Total"
          },
          "discount_total": {
            "type": "number",
            "description": "Discount Total"
          },
          "ffl_license": {
            "type": "string",
            "description": "FFL License Number"
          },
          "is_cr_transfer": {
            "type": "integer",
            "enum": [
              0,
              1
            ],
            "description": "C&R (03) Transfer"
          },
          "woo_ffl_rev": {
            "type": "integer",
            "description": "Woo FFL Revision"
          },
          "ffl_business_name": {
            "type": "string",
            "description": "FFL Business Name"
          },
          "ffl_phone": {
            "type": "string",
            "description": "FFL Phone"
          },
          "ffl_expiration": {
            "type": "string",
            "description": "FFL Expiration"
          },
          "ffl_premise_street": {
            "type": "string",
            "description": "Street"
          },
          "ffl_premise_city": {
            "type": "string",
            "description": "City"
          },
          "ffl_premise_state": {
            "type": "string",
            "description": "State"
          },
          "ffl_premise_zip": {
            "type": "string",
            "description": "ZIP"
          },
          "atf_ffl_record": {
            "type": "string",
            "description": "ATF FFL Record (Link: ATF FFL Record)"
          },
          "ffl_raw": {
            "type": "string",
            "description": "FFL Raw Meta (fallback)"
          },
          "cr_contact_name": {
            "type": "string",
            "description": "Collector Name (as printed on license)"
          },
          "cr_license_expiry": {
            "type": "string",
            "description": "C&R License Expiration"
          },
          "cr_premise_street": {
            "type": "string",
            "description": "Licensed Premises — Address 1"
          },
          "cr_premise_street2": {
            "type": "string",
            "description": "Address 2"
          },
          "cr_premise_city": {
            "type": "string",
            "description": "City"
          },
          "cr_premise_state": {
            "type": "string",
            "description": "State"
          },
          "cr_premise_zip": {
            "type": "string",
            "description": "ZIP"
          },
          "cr_verified_by": {
            "type": "string",
            "description": "Verified By (Link: User)"
          },
          "cr_verified_at": {
            "type": "string",
            "description": "Verified At"
          },
          "ship_to_name": {
            "type": "string",
            "description": "Ship To Name"
          },
          "ship_to_line1": {
            "type": "string",
            "description": "Address Line 1"
          },
          "ship_to_line2": {
            "type": "string",
            "description": "Address Line 2"
          },
          "ship_to_city": {
            "type": "string",
            "description": "City"
          },
          "ship_to_state": {
            "type": "string",
            "description": "State"
          },
          "ship_to_zip": {
            "type": "string",
            "description": "ZIP"
          },
          "refunds": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Woo_Online_Order_Refund"
            },
            "description": "Refunds"
          }
        },
        "required": [
          "woo_order_id",
          "order_status"
        ]
      },
      "Woo_Online_Order_Line": {
        "type": "object",
        "description": "Custom DocType (ffl_woo_sync); CRUD via /api/resource/Woo%20Online%20Order%20Line — see docs/api/frappe-rest.md.",
        "properties": {
          "item_code": {
            "type": "string",
            "description": "Item Code (Link: Item)"
          },
          "serial": {
            "type": "string",
            "description": "Serial No"
          },
          "woo_line_id": {
            "type": "string",
            "description": "Woo Line ID"
          },
          "qty": {
            "type": "integer",
            "description": "Qty"
          },
          "unit_price": {
            "type": "number",
            "description": "Unit Price"
          },
          "subtotal": {
            "type": "number",
            "description": "Subtotal"
          },
          "line_total": {
            "type": "number",
            "description": "Line Total"
          },
          "line_tax": {
            "type": "number",
            "description": "Line Tax"
          },
          "reservation_error": {
            "type": "string",
            "description": "Reservation Error"
          },
          "lane": {
            "type": "string",
            "description": "Lane"
          },
          "source_distributor": {
            "type": "string",
            "description": "Source Distributor"
          },
          "source_sku": {
            "type": "string",
            "description": "Source SKU"
          },
          "storage_location": {
            "type": "string",
            "description": "Taken From Location (Link: Storage Location)"
          },
          "preorder_slots": {
            "type": "integer",
            "description": "Pre-order Slots Taken"
          },
          "preorder_reserved": {
            "type": "number",
            "description": "Pre-order Units Put By"
          }
        }
      },
      "Woo_Online_Order_Refund": {
        "type": "object",
        "description": "Custom DocType (ffl_woo_sync); CRUD via /api/resource/Woo%20Online%20Order%20Refund — see docs/api/frappe-rest.md.",
        "properties": {
          "woo_refund_id": {
            "type": "string",
            "description": "Woo Refund ID"
          },
          "refund_amount": {
            "type": "number",
            "description": "Refund Amount"
          },
          "tax_refunded": {
            "type": "number",
            "description": "Tax Refunded"
          },
          "shipping_refunded": {
            "type": "number",
            "description": "Shipping Refunded"
          },
          "breakdown_status": {
            "type": "string",
            "enum": [
              "Fetched",
              "Pending",
              "Not in Woo",
              "Rejected"
            ],
            "description": "Breakdown"
          },
          "returned_lines": {
            "type": "string",
            "description": "Returned Lines"
          },
          "reason": {
            "type": "string",
            "description": "Reason"
          },
          "recorded_on": {
            "type": "string",
            "description": "Recorded On"
          }
        },
        "required": [
          "woo_refund_id"
        ]
      },
      "Woo_Online_Order_Serial": {
        "type": "object",
        "description": "Custom DocType (ffl_woo_sync); CRUD via /api/resource/Woo%20Online%20Order%20Serial — see docs/api/frappe-rest.md.",
        "properties": {
          "item_code": {
            "type": "string",
            "description": "Item Code (Link: Item)"
          },
          "woo_line_id": {
            "type": "string",
            "description": "Woo Line ID"
          },
          "unit_index": {
            "type": "integer",
            "description": "Unit #"
          },
          "confirmed_serial": {
            "type": "string",
            "description": "Confirmed Serial"
          },
          "stock_hold_serial": {
            "type": "string",
            "description": "Stock Hold Serial"
          },
          "reservation_error": {
            "type": "string",
            "description": "Reservation Error"
          },
          "fulfillment": {
            "type": "string",
            "enum": [
              "local",
              "to_store",
              "fds",
              "direct",
              "preorder"
            ],
            "description": "Fulfillment"
          }
        }
      },
      "WooCommerce_Settings": {
        "type": "object",
        "description": "Custom DocType (ffl_woo_sync); CRUD via /api/resource/WooCommerce%20Settings — see docs/api/frappe-rest.md.",
        "properties": {
          "store_url": {
            "type": "string",
            "description": "Store URL"
          },
          "consumer_key": {
            "type": "string",
            "description": "Consumer key"
          },
          "consumer_secret": {
            "type": "string",
            "description": "Consumer secret"
          },
          "webhook_secret": {
            "type": "string",
            "description": "Webhook secret"
          },
          "outbound_webhook_secret": {
            "type": "string",
            "description": "Outbound status webhook secret"
          },
          "send_customer_events": {
            "type": "integer",
            "enum": [
              0,
              1
            ],
            "description": "Send customer emails to the shop"
          },
          "auto_sync_enabled": {
            "type": "integer",
            "enum": [
              0,
              1
            ],
            "description": "Enable sync"
          },
          "reconcile_frequency": {
            "type": "string",
            "enum": [
              "Every 2 Hours",
              "Daily",
              "Weekly",
              "Disabled"
            ],
            "description": "Reconcile frequency"
          },
          "request_timeout_seconds": {
            "type": "integer",
            "description": "Request Timeout (s)"
          },
          "follow_category_tree": {
            "type": "integer",
            "enum": [
              0,
              1
            ],
            "description": "Follow the catalog category tree"
          },
          "connect_status": {
            "type": "string",
            "description": "Connect"
          },
          "last_push_at": {
            "type": "string",
            "description": "Last push"
          },
          "last_push_count": {
            "type": "integer",
            "description": "Items pushed"
          },
          "last_reconcile_at": {
            "type": "string",
            "description": "Last reconcile"
          },
          "last_order_audit_at": {
            "type": "string",
            "description": "Last order audit"
          },
          "last_sync_error": {
            "type": "string",
            "description": "Last error"
          }
        },
        "required": [
          "store_url"
        ]
      }
    }
  },
  "paths": {
    "/api/method/ffl_core.agreements.agreements_for_sale": {
      "post": {
        "tags": [
          "ffl_core"
        ],
        "summary": "Every active agreement and where this customer stands, for the register's Agreements button.",
        "description": "**Auth (derived from code):** Requires read permission on Customer (Frappe DocType permission check).\n\nSource: `apps/ffl_core/ffl_core/agreements.py:443`",
        "operationId": "ffl_core.agreements.agreements_for_sale",
        "responses": {
          "200": {
            "description": "{\"rows\": [{\"template\", \"scope\", \"requirement\", \"required\": whether this sale needs it, \"skippable\": whether a manager may let this sale go without it (:func:`skip_for_sale`), \"state\", \"expires_on\", \"agreement\", \"firearms\"}]} — every template once, except an Each firearm sold one with One copy per gun, once per gun. An Each firearm sold row lists the guns one copy is signed for in \"firearms\": [{\"serial_no\", \"item_code\", \"item_name\", \"rate\", \"state\"}] (the guns the sale needs it for, else every gun in the cart; empty when the cart has none); its \"state\" is signed once every one of them is, pending when the unsigned ones all have a copy out, else missing.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "customer": {
                    "type": "string",
                    "description": "Customer name (document id)."
                  },
                  "items": {
                    "description": "The cart: [{\"item_code\", \"serial_no\", \"rate\"}] (serial_no may hold several, one per line)."
                  },
                  "sale": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "description": "The POS Invoice, once saved."
                  }
                },
                "required": [
                  "customer"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_core.agreements.get_customer_agreements": {
      "post": {
        "tags": [
          "ffl_core"
        ],
        "summary": "The Agreements section of the Customer form.",
        "description": "**Auth (derived from code):** Requires read permission on Customer (Frappe DocType permission check).\n\nSource: `apps/ffl_core/ffl_core/agreements.py:986`",
        "operationId": "ffl_core.agreements.get_customer_agreements",
        "responses": {
          "200": {
            "description": "{\"rows\": [{\"name\", \"template\", \"serial_no\": every gun it covers, comma-separated, \"status\", \"signed_on\", \"signed_via\", \"expires_on\", \"signed_pdf\"}] newest first, \"can_manage\": whether the caller may void or record paper copies}.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "customer": {
                    "type": "string",
                    "description": "Customer name (document id)."
                  }
                },
                "required": [
                  "customer"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_core.agreements.load_for_signing": {
      "post": {
        "tags": [
          "webhooks"
        ],
        "summary": "What the signing page shows for a one-time link (Guest).",
        "description": "Only the customer's name, the agreement's title and text, and the store's\nname — nothing else about the customer. Every invalid, used, void or\nexpired link gets the same error. 30 calls an hour per link and 600 per IP\naddress. A copy sent before its template's text changed is shown (and from\nthen on carries) the current text.\n\n**Auth (derived from code):** Guest — no session; the endpoint verifies the caller itself (HMAC signature, HTTP Basic credentials or a one-time token).\n\nSource: `apps/ffl_core/ffl_core/agreements.py:1081`",
        "operationId": "ffl_core.agreements.load_for_signing",
        "responses": {
          "200": {
            "description": "{\"customer_name\", \"title\", \"body_html\", \"store_name\", \"minors_need_guardian\", \"minor_by_dob\": true / false from the customer's date of birth, or null when the store keeps none (the page then asks)}.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "security": [],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "token": {
                    "type": "string",
                    "description": "The token from the link's ``#t=`` fragment."
                  }
                },
                "required": [
                  "token"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_core.agreements.record_paper_agreement": {
      "post": {
        "tags": [
          "ffl_core"
        ],
        "summary": "Manager records a copy the customer signed on paper.",
        "description": "The scan must already be attached to this Customer Agreement; it is made\nprivate and becomes the signed copy. The copy turns Signed via Paper, its\nexpiry counts from the date on the paper, and who recorded it, when, and the\nfile go on the timeline. A missing signature can never be waived: without a\nsigned scan there is nothing to record.\n\n**Auth (derived from code):** Roles: Sales Manager / System Manager\n\nSource: `apps/ffl_core/ffl_core/agreements.py:923`",
        "operationId": "ffl_core.agreements.record_paper_agreement",
        "responses": {
          "200": {
            "description": "{\"name\", \"status\", \"expires_on\", \"signed_pdf\"}.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "name": {
                    "type": "string",
                    "description": "The Pending Customer Agreement."
                  },
                  "file_url": {
                    "type": "string",
                    "description": "The attached scan (PDF or image)."
                  },
                  "signer_name": {
                    "type": "string",
                    "description": "Name as signed on the paper."
                  },
                  "paper_signed_on": {
                    "type": "string",
                    "description": "Date written on the paper (YYYY-MM-DD), not in the future."
                  },
                  "participant_is_minor": {
                    "type": "integer",
                    "description": "1 when the participant is under 18 (then a Parent or Guardian signed).",
                    "default": 0
                  },
                  "signer_relationship": {
                    "type": "string",
                    "description": "Self, Parent or Guardian.",
                    "default": "Self"
                  }
                },
                "required": [
                  "name",
                  "file_url",
                  "signer_name",
                  "paper_signed_on"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_core.agreements.regenerate_signed_pdf": {
      "post": {
        "tags": [
          "ffl_core"
        ],
        "summary": "Build a signed copy's PDF again (when the background job failed).",
        "description": "**Auth (derived from code):** Roles: Sales User / Sales Manager / Stock Manager / System Manager\n\nSource: `apps/ffl_core/ffl_core/agreements.py:1011`",
        "operationId": "ffl_core.agreements.regenerate_signed_pdf",
        "responses": {
          "200": {
            "description": "{\"signed_pdf\": file URL}.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "name": {
                    "type": "string",
                    "description": "A Customer Agreement signed on a tablet or by link."
                  }
                },
                "required": [
                  "name"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_core.agreements.request_agreement": {
      "post": {
        "tags": [
          "ffl_core"
        ],
        "summary": "Send a customer an agreement to sign.",
        "description": "Creates the customer's Pending copy of the template, or re-issues the one\nalready pending (its old link stops working and its text is rendered again).\nWhile that copy still has a working link — the customer may be signing on the\ntablet right now — nothing changes unless ``replace`` is 1: the answer is\n``{\"name\", \"link_open\": True, \"token_expires\"}`` so the counter can ask first.\n\n**Auth (derived from code):** Roles: Sales User / Sales Manager / Stock Manager / System Manager\n\nSource: `apps/ffl_core/ffl_core/agreements.py:733`",
        "operationId": "ffl_core.agreements.request_agreement",
        "responses": {
          "200": {
            "description": "{\"name\": the Customer Agreement, \"deliver\", \"token_expires\"} plus, for ``qr``, \"sign_url\" and \"qr_svg\" (an SVG data URI); for ``email``, \"email\". The link itself is never stored.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "customer": {
                    "type": "string",
                    "description": "Customer name (document id)."
                  },
                  "template": {
                    "type": "string",
                    "description": "Agreement Template name; must be active."
                  },
                  "deliver": {
                    "type": "string",
                    "description": "``tablet`` — send the link to a paired signing tablet (``terminal``; ``ffl_core.signing_terminal``), which opens it by itself once the request commits (a caller that never commits sends nothing); ``qr`` — return the signing link and a QR code for the counter; ``email`` — email the link to the customer (refused when the customer has no email address); ``none`` — only create the Pending copy (a manager then records a paper copy on it).",
                    "default": "qr"
                  },
                  "replace": {
                    "type": "integer",
                    "description": "1 to re-issue even though the pending copy's link still works.",
                    "default": 0
                  },
                  "terminal": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "description": "Signing Terminal name, for ``tablet``; must be active and paired."
                  },
                  "serial_no": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "description": "The gun, for an Each firearm sold template (it or *firearms* is required there)."
                  },
                  "price": {
                    "type": [
                      "number",
                      "null"
                    ],
                    "description": "The gun's price in this sale, for the text's ``{{ price }}``."
                  },
                  "reference_doctype": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "description": "For a Per document template (required there): the record's DocType."
                  },
                  "reference_name": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "description": "That record's name; the caller must be able to read it, and the record's ``agreement_context()`` fills the text's placeholders."
                  },
                  "firearms": {
                    "description": "For an Each firearm sold template, several guns signed for at once: [{\"serial_no\", \"price\"}]. One copy covers them all (refused for a template with One copy per gun); a pending copy covering any of them is the one re-issued."
                  }
                },
                "required": [
                  "customer",
                  "template"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_core.agreements.skip_approvers": {
      "post": {
        "tags": [
          "ffl_core"
        ],
        "summary": "Who can approve :func:`skip_for_sale` for this user.",
        "description": "**Auth (derived from code):** Roles: Sales User / Sales Manager / Stock Manager / System Manager\n\nSource: `apps/ffl_core/ffl_core/agreements.py:599`",
        "operationId": "ffl_core.agreements.skip_approvers",
        "responses": {
          "200": {
            "description": "{\"self\": whether a manager is signed in (they approve their own), \"approvers\": the managers to pick from otherwise: [{\"user\", \"full_name\", \"has_pin\", \"pin_off\"}]}.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        }
      }
    },
    "/api/method/ffl_core.agreements.skip_for_sale": {
      "post": {
        "tags": [
          "ffl_core"
        ],
        "summary": "A manager lets the next sale to *customer* from this screen go without the agreements its cart needs.",
        "description": "Only what the cart's Items ask for (a Required by item template, the used-gun one say) can be\nskipped — never one every sale needs or one an extension asks for. The approval covers the\nagreements unsigned for this cart now: a sale that turns out to need anything else is refused\nas usual and does not use it up. A Sales / System Manager signed in approves their own; anyone\nelse names a manager, who types their counter PIN (or password) — the price approval's list\nand checks, lockouts included. Good for :data:`SKIP_MINUTES` minutes, once, for the user who\nasked and this customer: the sale gate (:func:`refuse_missing_required`) takes it, and on\nsubmit what was unsigned, who approved and why go on the sale's timeline.\n\n**Auth (derived from code):** Roles: Sales User / Sales Manager / Stock Manager / System Manager\n\nSource: `apps/ffl_core/ffl_core/agreements.py:550`",
        "operationId": "ffl_core.agreements.skip_for_sale",
        "responses": {
          "200": {
            "description": "{\"approver\", \"approver_name\", \"expires_in\": seconds, \"skipped\": [{\"template\", \"serial_no\"}]}.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "customer": {
                    "type": "string",
                    "description": "Customer name (document id)."
                  },
                  "items": {
                    "description": "The cart, as :func:`agreements_for_sale` reads it."
                  },
                  "sale": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "description": "The POS Invoice, once saved."
                  },
                  "approver": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "description": "The manager's user id (from :func:`skip_approvers`); ignored for a manager signed in."
                  },
                  "pin": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "description": "The approver's counter PIN."
                  },
                  "password": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "description": "Or their password."
                  },
                  "reason": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "description": "Why (optional)."
                  }
                },
                "required": [
                  "customer"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_core.agreements.submit_signature": {
      "post": {
        "tags": [
          "webhooks"
        ],
        "summary": "Sign an agreement through a one-time link (Guest).",
        "description": "Checked before anything is written: the \"I agree\" tick, the typed name, the\ntoken (same error for every invalid one), the signature (a PNG of at most\n500 KB and 2000 px with ink on it) and the age rule. A link opened as a QR\ncode at the counter, or on a paired signing tablet (its device key sent as\n``terminal_secret``; the copy records which tablet), is recorded as signed on\na Tablet, an emailed one as Remote. The link is used up; the signed PDF is built and emailed afterwards.\nWhen the template's text changed after the page was opened, nothing is signed\nand the signer is asked to reload and read the new text. 10 calls an hour per\nlink and 300 per IP address.\n\n**Auth (derived from code):** Guest — no session; the endpoint verifies the caller itself (HMAC signature, HTTP Basic credentials or a one-time token).\n\nSource: `apps/ffl_core/ffl_core/agreements.py:1164`",
        "operationId": "ffl_core.agreements.submit_signature",
        "responses": {
          "200": {
            "description": "{\"signed\": true, \"store_name\"}.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "security": [],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "token": {
                    "type": "string",
                    "description": "The token from the link's ``#t=`` fragment."
                  },
                  "signature": {
                    "type": "string",
                    "description": "The drawn signature as a PNG data URL."
                  },
                  "agreed": {
                    "type": "integer",
                    "description": "1 — the signer ticked \"I agree\"."
                  },
                  "signer_name": {
                    "type": "string",
                    "description": "Name typed by the signer."
                  },
                  "participant_is_minor": {
                    "type": "integer",
                    "description": "1 when the signer declares the participant is under 18 (ignored when the store keeps the customer's date of birth).",
                    "default": 0
                  },
                  "signer_relationship": {
                    "type": "string",
                    "description": "Self, or Parent / Guardian when signing for a minor.",
                    "default": "Self"
                  },
                  "terminal_secret": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "description": "The signing tablet's device key, when signed on one."
                  }
                },
                "required": [
                  "token",
                  "signature",
                  "agreed",
                  "signer_name"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_core.agreements.void_agreement": {
      "post": {
        "tags": [
          "ffl_core"
        ],
        "summary": "Manager voids a copy (sent by mistake, signed by the wrong person).",
        "description": "A Pending copy's link stops working. The copy is kept, marked Void, and the\nreason goes on its timeline.\n\n**Auth (derived from code):** Roles: Sales Manager / System Manager\n\nSource: `apps/ffl_core/ffl_core/agreements.py:895`",
        "operationId": "ffl_core.agreements.void_agreement",
        "responses": {
          "200": {
            "description": "{\"name\", \"status\": \"Void\"}.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "name": {
                    "type": "string",
                    "description": "Customer Agreement name."
                  },
                  "reason": {
                    "type": "string",
                    "description": "Why (required)."
                  }
                },
                "required": [
                  "name",
                  "reason"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_core.api.action_catalog.list_actions": {
      "post": {
        "tags": [
          "ffl_core"
        ],
        "summary": "Search the server endpoints the signed-in user can run, across every installed app.",
        "description": "Reads the api_catalog.json each app ships (core apps and installed extensions),\ndrops guest endpoints (webhooks), and keeps the rows whose derived gate the caller\npasses: a role list the caller holds some role of, or a DocType permission the\ncaller has. Rows only the call itself can decide (soft filters, runtime role lists,\nan extension switch, no gate at entry) are kept with runnable \"checked at call time\".\nThe endpoint still checks the caller when it is called.\n\n**Auth (derived from code):** Any authenticated user — no explicit role gate at function entry (deliberate open reads document this in Permissions).\n\n**Permissions:** Any signed-in desk user (System User); each user sees only the endpoints their roles and DocType permissions reach.\n\nSource: `apps/ffl_core/ffl_core/api/action_catalog.py:142`",
        "operationId": "ffl_core.api.action_catalog.list_actions",
        "responses": {
          "200": {
            "description": "list: Rows of {method, module, summary, args [{name, type, required}], http, roles or perm or gate, switch (when an extension switch applies), runnable (true or \"checked at call time\")}; with method, at most one row that also carries description, returns, source and each argument's desc."
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "query": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "description": "Words matched against the dotted path, argument names and summary; best matches first."
                  },
                  "module": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "description": "A dotted prefix, e.g. \"ffl_integrations.gunbroker\"; only endpoints under it."
                  },
                  "method": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "description": "One exact dotted path; returns that endpoint's full row (description, Returns text and every argument's description) or an empty list."
                  },
                  "limit": {
                    "type": "integer",
                    "description": "Rows returned, 1 to 100 (default 25)."
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_core.api.agent.firearm_stock_summary": {
      "post": {
        "tags": [
          "ffl_core"
        ],
        "summary": "How many firearms the store has on hand, and how many of them can be sold.",
        "description": "A gun is on hand while its Serial No is Active. It is not for sale when the POS\npicker would not offer it: held on a ticket or order, reserved by a web or\nGunBroker order, consigned out, or a customer's transfer gun.\n\n**Auth (derived from code):** Roles resolved at runtime via `STOCK_READ_ROLES`.\n\nSource: `apps/ffl_core/ffl_core/api/agent.py:21`",
        "operationId": "ffl_core.api.agent.firearm_stock_summary",
        "responses": {
          "200": {
            "description": "{on_hand, for_sale, not_for_sale, antiques, by_warehouse: {warehouse: count}, by_type: {firearm_type: count}}. Antiques are counted in on_hand and are not in the A&D book.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        }
      }
    },
    "/api/method/ffl_core.api.agent.item_stock": {
      "post": {
        "tags": [
          "ffl_core"
        ],
        "summary": "Quantity on hand per item across all warehouses, for non-gun items.",
        "description": "**Auth (derived from code):** Requires read permission on Item (Frappe DocType permission check).\n\nSource: `apps/ffl_core/ffl_core/api/agent.py:78`",
        "operationId": "ffl_core.api.agent.item_stock",
        "responses": {
          "200": {
            "description": "{item_code: total_actual_qty}.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "item_codes": {
                    "type": "array",
                    "description": "Item codes — list, JSON list or comma-separated string."
                  }
                },
                "required": [
                  "item_codes"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_core.api.agent.serials_for_sale": {
      "post": {
        "tags": [
          "ffl_core"
        ],
        "summary": "The units of each firearm item the counter would sell now, with their price.",
        "description": "**Auth (derived from code):** Roles: Sales User / Sales Manager / Stock Manager / System Manager\n\nSource: `apps/ffl_core/ffl_core/api/agent.py:63`",
        "operationId": "ffl_core.api.agent.serials_for_sale",
        "responses": {
          "200": {
            "description": "{item_code: [{\"serial\", \"sell_price\", \"purchase_rate\"}, ...]}, cheapest first.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "item_codes": {
                    "type": "array",
                    "description": "Item codes — list, JSON list or comma-separated string."
                  }
                },
                "required": [
                  "item_codes"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_core.api.atf_link.create_party_from_atf": {
      "post": {
        "tags": [
          "ffl_core"
        ],
        "summary": "Create a dealer Customer/Supplier from an ATF FFL Record (idempotent).",
        "description": "Sets is_ffl_dealer and the atf_ffl_record link; the party's validate\nhook then fills the license fields from the record. If a party already\ncarries the record's FFL number it is returned as-is (the link is\nhealed if missing) — never duplicated or renamed.\n\n**Auth (derived from code):** Roles: Sales User / Purchase User / Stock Manager / System Manager\n\n**Permissions:** Sales User / Purchase User / Stock Manager / System Manager.\n\nSource: `apps/ffl_core/ffl_core/api/atf_link.py:18`",
        "operationId": "ffl_core.api.atf_link.create_party_from_atf",
        "responses": {
          "200": {
            "description": "{\"name\": <party name>, \"created\": bool} — created=False when an existing party with this FFL number was reused.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "record": {
                    "type": "string",
                    "description": "ATF FFL Record name (the directory row to build from)."
                  },
                  "party_type": {
                    "type": "string",
                    "description": "\"Customer\" or \"Supplier\"."
                  }
                },
                "required": [
                  "record",
                  "party_type"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_core.api.cash_drawer.clear_paid_outside": {
      "post": {
        "tags": [
          "ffl_core"
        ],
        "summary": "Take back a \"paid outside the system\" mark: the purchase is listed and its seller payment can be recorded again.",
        "description": "The mark is cleared on every receipt of the amendment line that carries it (an amendment answers to its cancelled\noriginal's mark), so clearing it on the amendment really clears it.\n\n**Auth (derived from code):** Roles: Sales Manager / System Manager\n\nSource: `apps/ffl_core/ffl_core/api/cash_drawer.py:373`",
        "operationId": "ffl_core.api.cash_drawer.clear_paid_outside",
        "responses": {
          "200": {
            "description": "{purchase_receipt, cleared, receipts}; receipts are the ones the mark was taken off.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "purchase_receipt": {
                    "type": "string",
                    "description": "The Purchase Receipt that carries the mark, or an amendment of it."
                  }
                },
                "required": [
                  "purchase_receipt"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_core.api.cash_drawer.close_day": {
      "post": {
        "tags": [
          "ffl_core"
        ],
        "summary": "Count the drawer and close the day.",
        "description": "Closes the open POS shifts, books any difference from the books and carries the count forward as tomorrow's opening.\nA company's very first count sets the books to the physical drawer (against the bank) instead of booking a difference;\na later count first books any correction made since to the days before the first count (a true-up, also against\nthe bank), since that money was never in the drawer.\n\n**Auth (derived from code):** Roles: Sales User / Sales Manager / Stock Manager / System Manager\n\nSource: `apps/ffl_core/ffl_core/api/cash_drawer.py:180`",
        "operationId": "ffl_core.api.cash_drawer.close_day",
        "responses": {
          "200": {
            "description": "{close, expected, counted, variance, first_count, days_covered, covers_from, variance_je, cutoff_je, trueup_je, pos_closing_entries, pos_errors}.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "company": {
                    "type": "string",
                    "description": "Company whose drawer is counted."
                  },
                  "counted": {
                    "description": "The cash counted in the drawer, in dollars (0 is allowed)."
                  },
                  "reason": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "description": "Why the drawer is over or short; required when the difference reaches the limit set in Cash Drawer Settings (it never blocks a close below it)."
                  },
                  "expected_seen": {
                    "description": "The expected cash the screen showed; the close is refused if the books moved since."
                  }
                },
                "required": [
                  "company",
                  "counted"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_core.api.cash_drawer.get_log": {
      "post": {
        "tags": [
          "ffl_core"
        ],
        "summary": "Every cash movement in a date range, oldest first, with the drawer's running balance.",
        "description": "Sales, refunds, seller payments, deposits, cash from the bank, expenses, count differences and the\nfirst count, plus register sales not posted yet. The balance starts from the books' cash before\n``from_date``.\n\n**Auth (derived from code):** Roles: Sales User / Sales Manager / Stock Manager / System Manager / Accounts User / Accounts Manager\n\nSource: `apps/ffl_core/ffl_core/api/cash_drawer.py:256`",
        "operationId": "ffl_core.api.cash_drawer.get_log",
        "responses": {
          "200": {
            "description": "{company, from_date, to_date, opening, closing, cash_in, cash_out, lines: [{posting_date, when, kind, label, detail, by, voucher_type, voucher_no, amount, balance}]}.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "company": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "description": "Company to show; defaults to the user's company."
                  },
                  "from_date": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "description": "First posting date (YYYY-MM-DD); defaults to 6 days before to_date."
                  },
                  "to_date": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "description": "Last posting date (YYYY-MM-DD); defaults to today."
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_core.api.cash_drawer.get_today": {
      "post": {
        "tags": [
          "ffl_core"
        ],
        "summary": "Everything the Cash Drawer page shows.",
        "description": "What the drawer should hold now, what moved it today or since the last close (whichever is later), today's close,\ntoday's seller payments by bank, and the choices for the forms. Read only: it never creates an account or changes a default.\n\n**Auth (derived from code):** Roles: Sales User / Sales Manager / Stock Manager / System Manager\n\nSource: `apps/ffl_core/ffl_core/api/cash_drawer.py:38`",
        "operationId": "ffl_core.api.cash_drawer.get_today",
        "responses": {
          "200": {
            "description": "{company, is_manager, expected, gl_balance, pending, history, opening, last_close, closed_today, can_undo_close, first_count, open_shifts, bank_account, threshold, expense_cap, expense_accounts, cash_in, cash_out (the lines' cash in and out, both positive; count differences and the first count are neither), lines: [{kind, label, direction, voucher_type, voucher_no, amount, when, detail, entry, can_undo, can_fix, acquisition, purchase_receipt}], older_lines, older_net, other, bank_payouts: [{entry, acquisition, purchase_receipt, serial, amount, method, detail, can_fix}], unpaid_goods_receipts: [{purchase_receipt, customer, amount, method, posting_date, can_fix}] (Receive Goods purchases from private sellers received since cash tracking started with no seller payment standing: never paid, or undone; method is the last one recorded, if any), payout_methods}.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "company": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "description": "Company to show; defaults to the user's company."
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_core.api.cash_drawer.mark_paid_outside": {
      "post": {
        "tags": [
          "ffl_core"
        ],
        "summary": "Mark a Receive Goods purchase as paid to its private seller outside the system (a hand journal entry, a check",
        "description": "booked in QuickBooks).\n\nBooks nothing. The receipt leaves the list of purchases with no seller payment, and no seller payment can be\nrecorded for it until the mark is cleared. Refused for a receipt paid in the system.\n\n**Auth (derived from code):** Roles: Sales Manager / System Manager\n\nSource: `apps/ffl_core/ffl_core/api/cash_drawer.py:354`",
        "operationId": "ffl_core.api.cash_drawer.mark_paid_outside",
        "responses": {
          "200": {
            "description": "{purchase_receipt, note, by, on}.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "purchase_receipt": {
                    "type": "string",
                    "description": "The Purchase Receipt Receive Goods made for the purchase."
                  },
                  "note": {
                    "type": "string",
                    "description": "How the seller was paid (the journal entry, the check number); required."
                  }
                },
                "required": [
                  "purchase_receipt",
                  "note"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_core.api.cash_drawer.preview_close": {
      "post": {
        "tags": [
          "ffl_core"
        ],
        "summary": "What closing the day with this count would do, without recording anything.",
        "description": "**Auth (derived from code):** Roles: Sales User / Sales Manager / Stock Manager / System Manager\n\nSource: `apps/ffl_core/ffl_core/api/cash_drawer.py:164`",
        "operationId": "ffl_core.api.cash_drawer.preview_close",
        "responses": {
          "200": {
            "description": "{expected, counted, variance, threshold, first_count, needs_reason}; variance is counted minus expected (negative = short).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "company": {
                    "type": "string",
                    "description": "Company whose drawer is counted."
                  },
                  "counted": {
                    "description": "The cash counted in the drawer, in dollars."
                  }
                },
                "required": [
                  "company",
                  "counted"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_core.api.cash_drawer.record_deposit": {
      "post": {
        "tags": [
          "ffl_core"
        ],
        "summary": "Record cash taken to the bank: Dr Operating Bank / Cr Cash.",
        "description": "**Auth (derived from code):** Roles: Sales User / Sales Manager / Stock Manager / System Manager\n\nSource: `apps/ffl_core/ffl_core/api/cash_drawer.py:204`",
        "operationId": "ffl_core.api.cash_drawer.record_deposit",
        "responses": {
          "200": {
            "description": "{entry, journal_entry, amount, company}.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "company": {
                    "type": "string",
                    "description": "Company whose drawer the cash left."
                  },
                  "amount": {
                    "description": "Dollars deposited."
                  },
                  "reference": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "description": "Optional deposit slip or bank reference."
                  }
                },
                "required": [
                  "company",
                  "amount"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_core.api.cash_drawer.record_expense": {
      "post": {
        "tags": [
          "ffl_core"
        ],
        "summary": "Record a small expense paid in cash: Dr the expense account / Cr Cash.",
        "description": "Needs a memo (a receipt photo is optional), stays under the cash-expense limit and goes only to an allowed expense account.\n\n**Auth (derived from code):** Roles: Sales User / Sales Manager / Stock Manager / System Manager\n\nSource: `apps/ffl_core/ffl_core/api/cash_drawer.py:220`",
        "operationId": "ffl_core.api.cash_drawer.record_expense",
        "responses": {
          "200": {
            "description": "{entry, journal_entry, amount, company}.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "company": {
                    "type": "string",
                    "description": "Company whose drawer paid."
                  },
                  "amount": {
                    "description": "Dollars paid, tax included."
                  },
                  "expense_account": {
                    "type": "string",
                    "description": "One of the accounts in the expense list of the page."
                  },
                  "memo": {
                    "type": "string",
                    "description": "What the money was spent on."
                  },
                  "receipt": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "description": "The uploaded receipt's file URL, if any."
                  }
                },
                "required": [
                  "company",
                  "amount",
                  "expense_account",
                  "memo"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_core.api.cash_drawer.record_from_bank": {
      "post": {
        "tags": [
          "ffl_core"
        ],
        "summary": "Record cash taken out of the bank and put in the drawer: Dr Cash / Cr Operating Bank.",
        "description": "**Auth (derived from code):** Roles: Sales User / Sales Manager / Stock Manager / System Manager\n\nSource: `apps/ffl_core/ffl_core/api/cash_drawer.py:240`",
        "operationId": "ffl_core.api.cash_drawer.record_from_bank",
        "responses": {
          "200": {
            "description": "{entry, journal_entry, amount, company}.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "company": {
                    "type": "string",
                    "description": "Company whose drawer the cash went into."
                  },
                  "amount": {
                    "description": "Dollars added to the drawer."
                  },
                  "reference": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "description": "Optional withdrawal slip or bank reference."
                  }
                },
                "required": [
                  "company",
                  "amount"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_core.api.cash_drawer.record_goods_payout": {
      "post": {
        "tags": [
          "ffl_core"
        ],
        "summary": "Record how the private seller of a Receive Goods purchase was paid: change the method, record it again after an",
        "description": "undo, or record the first payment of a receipt that never had one.\n\nBooks Dr Stock Received But Not Billed / Cr Cash (or the bank) for what the receipt owes the seller, replacing the\npayment recorded, if any. Refused once a count was taken after that payment, for a receipt received before cash\ntracking started (the accountant's), for one marked as paid outside the system, when the receipt owes nothing\nnow, and when the same goods are still paid on a cancelled receipt of this seller (a new receipt typed for goods\nalready paid: undo that payment, or amend the cancelled receipt, instead); a refusal leaves the payment recorded\nas it was.\n\n**Auth (derived from code):** Roles: Sales Manager / System Manager\n\nSource: `apps/ffl_core/ffl_core/api/cash_drawer.py:390`",
        "operationId": "ffl_core.api.cash_drawer.record_goods_payout",
        "responses": {
          "200": {
            "description": "{entry, journal_entry, amount, company, excluded}: the payment booked.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "purchase_receipt": {
                    "type": "string",
                    "description": "The Purchase Receipt Receive Goods made for the purchase."
                  },
                  "method": {
                    "type": "string",
                    "description": "Cash, Zelle, Check or ACH."
                  },
                  "reference": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "description": "The check number, Zelle confirmation or ACH reference; required unless Cash."
                  }
                },
                "required": [
                  "purchase_receipt",
                  "method"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_core.api.cash_drawer.record_payout": {
      "post": {
        "tags": [
          "ffl_core"
        ],
        "summary": "Change the method of a gun's own seller payment (made the old way, before a pay-now buy became a receipt paid with",
        "description": "it), or book one that was undone again.\n\nBooks Dr Stock Adjustment / Cr Cash (or the bank) at the net last paid. A first payment is refused: a seller is paid\nwith the gun's receipt (record_goods_payout). Changing a recorded payment is for a System Manager.\n\n**Auth (derived from code):** Roles: Sales Manager / System Manager\n\nSource: `apps/ffl_core/ffl_core/api/cash_drawer.py:335`",
        "operationId": "ffl_core.api.cash_drawer.record_payout",
        "responses": {
          "200": {
            "description": "{entry, journal_entry, amount, company}.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "acquisition": {
                    "type": "string",
                    "description": "The FFL Acquisition name (a trade-in or other purchase from a private seller)."
                  },
                  "method": {
                    "type": "string",
                    "description": "Cash, Zelle, Check or ACH."
                  }
                },
                "required": [
                  "acquisition",
                  "method"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_core.api.cash_drawer.undo_close": {
      "post": {
        "tags": [
          "ffl_core"
        ],
        "summary": "Undo the latest count of the drawer: its difference (or first-count) entry is cancelled.",
        "description": "The day reads as not counted again; the POS shifts it closed stay closed.\n\n**Auth (derived from code):** Roles: Sales Manager / System Manager\n\nSource: `apps/ffl_core/ffl_core/api/cash_drawer.py:319`",
        "operationId": "ffl_core.api.cash_drawer.undo_close",
        "responses": {
          "200": {
            "description": "{close, status}.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "close": {
                    "type": "string",
                    "description": "The Cash Drawer Close name; it must be the latest close of its company."
                  }
                },
                "required": [
                  "close"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_core.api.cash_drawer.undo_entry": {
      "post": {
        "tags": [
          "ffl_core"
        ],
        "summary": "Undo a cash entry (deposit, cash from the bank, expense or seller payment): its Journal Entry is cancelled.",
        "description": "A seller payment for a Receive Goods receipt is undone like the others (the money is back where it came from); a\ntrade-in ticket's payout is taken back by cancelling the ticket.\n\nRefused once a count was taken after the entry.\n\n**Auth (derived from code):** Roles: Sales Manager / System Manager\n\nSource: `apps/ffl_core/ffl_core/api/cash_drawer.py:297`",
        "operationId": "ffl_core.api.cash_drawer.undo_entry",
        "responses": {
          "200": {
            "description": "{entry, status}.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "entry": {
                    "type": "string",
                    "description": "The Cash Drawer Entry name."
                  }
                },
                "required": [
                  "entry"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_core.api.changelog.get_changelog": {
      "post": {
        "tags": [
          "ffl_core"
        ],
        "summary": "The current POS version and all release notes, newest first.",
        "description": "Backs the sidebar-header menu → \"What's New in POS\" dialog (`gunstore.showWhatsNew()`).\nAny logged-in desk user may call it: the notes are static files shipped\nwith the code, nothing store-specific.\n\n**Auth (derived from code):** Any authenticated user — no explicit role gate at function entry (deliberate open reads document this in Permissions).\n\nSource: `apps/ffl_core/ffl_core/api/changelog.py:41`",
        "operationId": "ffl_core.api.changelog.get_changelog",
        "responses": {
          "200": {
            "description": "dict: `{\"version\": \"1.0.0-beta.1\", \"entries\": [[\"1.0.0-beta.1\", \"<markdown>\"], …]}` — `entries` sorted by semantic version, newest first."
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        }
      }
    },
    "/api/method/ffl_core.api.connector.connector_identity": {
      "get": {
        "tags": [
          "ffl_core"
        ],
        "summary": "Who this bearer token belongs to, and whether it was issued to a connector.",
        "description": "**Auth (derived from code):** Any authenticated user — no explicit role gate at function entry (deliberate open reads document this in Permissions).\n\nSource: `apps/ffl_core/ffl_core/api/connector.py:101`",
        "operationId": "ffl_core.api.connector.connector_identity",
        "responses": {
          "200": {
            "description": "{user, full_name, client_id, client_name, connector, enabled, web_access, expires_at} — connector is true only for a client created by dynamic registration; enabled says whether that surface is switched on (answered, not refused: a switched-off server must not look like a bad token, or clients would loop on sign-in); web_access is the user's level on a website surface (\"manager\", \"viewer\" or \"\", by role alone; always \"\" for cpa and full); expires_at is the token's expiry as a Unix timestamp.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "parameters": [
          {
            "name": "surface",
            "in": "query",
            "required": false,
            "schema": {
              "type": [
                "string",
                "null"
              ]
            },
            "description": "\"cpa\", \"full\" or \"web_ro\" — the connector asking."
          }
        ]
      }
    },
    "/api/method/ffl_core.api.connector.log_connector_call": {
      "post": {
        "tags": [
          "ffl_core"
        ],
        "summary": "Record one connector tool call in Connector Audit Log.",
        "description": "Called before the tool runs (phase \"started\" — the connector refuses to run\nthe tool if this fails, so nothing happens unrecorded) and once after it\n(phase \"ok\" / \"failed\", with the log name returned by the first call). A row\nmoves from Started to its outcome exactly once; it cannot be rewritten. On the\nwebsite surface a call refused here (switch off, no website role) is still\nrecorded, as Failed with the reason, before the refusal.\n\n**Auth (derived from code):** Any authenticated user — no explicit role gate at function entry (deliberate open reads document this in Permissions).\n\nSource: `apps/ffl_core/ffl_core/api/connector.py:130`",
        "operationId": "ffl_core.api.connector.log_connector_call",
        "responses": {
          "200": {
            "description": "{log} — the Connector Audit Log name.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "tool": {
                    "type": "string",
                    "description": "Tool name."
                  },
                  "surface": {
                    "type": "string",
                    "description": "\"cpa\", \"full\" or \"web_ro\"."
                  },
                  "phase": {
                    "type": "string",
                    "description": "\"started\", \"ok\" or \"failed\".",
                    "default": "started"
                  },
                  "arguments": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "description": "The tool arguments as JSON; secret-looking keys are masked."
                  },
                  "log": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "description": "The Connector Audit Log returned by the \"started\" call (for \"ok\"/\"failed\")."
                  },
                  "error": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "description": "The error text, for \"failed\"."
                  }
                },
                "required": [
                  "tool",
                  "surface"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_core.api.cost_correction.correct_serial_cost": {
      "post": {
        "tags": [
          "ffl_core"
        ],
        "summary": "Correct the acquisition cost of one in-stock, owned firearm serial.",
        "description": "Books a Stock Reconciliation at today's date (the discovery period).\nA pay-on-sale gun whose cost is still parked in SRBNB routes the delta\nto SRBNB instead of Stock Adjustment, keeping the supplier liability\nconsistent (PS-7).\n\n**Auth (derived from code):** Roles: Stock Manager / System Manager\n\n**Permissions:** Stock Manager / System Manager.\n\nSource: `apps/ffl_core/ffl_core/api/cost_correction.py:87`",
        "operationId": "ffl_core.api.cost_correction.correct_serial_cost",
        "responses": {
          "200": {
            "description": "{ok, serial, stock_reconciliation, old_cost, new_cost, delta, posting_date, payout_adjustment, payout_note, source_of_cost_hint}; payout_adjustment is the Journal Entry that books the difference when the seller's payment for this gun was recorded in the cash drawer, else None; payout_note says why nothing was booked when the box was ticked.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "serial": {
                    "type": "string",
                    "description": "Serial No name — must be an Active firearm the store OWNS (``is_consignment=0``). Its warehouse does not matter: a gun out on consignment at a dealer is still ours and is correctable."
                  },
                  "new_cost": {
                    "description": "New acquisition cost, strictly > 0 (rounded to 2dp)."
                  },
                  "reason": {
                    "type": "string",
                    "description": "Required free-text audit reason."
                  },
                  "payout_was_different": {
                    "description": "1 when the amount actually paid to the seller was different (the gun's seller payment was recorded in the cash drawer, on its own or with its Receive Goods receipt): the difference is then booked against the same cash or bank account. Default 0: only the cost changes and no cash moves.",
                    "default": 0
                  }
                },
                "required": [
                  "serial",
                  "new_cost",
                  "reason"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_core.api.cost_correction.list_item_serials_for_cost": {
      "post": {
        "tags": [
          "ffl_core"
        ],
        "summary": "In-stock, owned serials of a firearm Item, for the correction dialog.",
        "description": "Read-only. Excludes sold/inactive serials and guns consigned TO us\n(``is_consignment=1``) — mirrored on the picker. Guns of OURS that are out\non consignment at a dealer ARE listed: they stay correctable, and a\npicker that hid them would rebuild the dead end the server guard just\ndropped.\n\n**Auth (derived from code):** Roles: Stock Manager / System Manager\n\n**Permissions:** Stock Manager / System Manager.\n\nSource: `apps/ffl_core/ffl_core/api/cost_correction.py:337`",
        "operationId": "ffl_core.api.cost_correction.list_item_serials_for_cost",
        "responses": {
          "200": {
            "description": "{item_code, is_firearm, serials: [{serial, warehouse, purchase_rate, valuation, cash_payout, goods_payout}]}; cash_payout says the seller's payment for the gun was recorded in the cash drawer -- on its own, or with the Receive Goods receipt it came in on (goods_payout names that receipt's payment, else null).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "item_code": {
                    "type": "string",
                    "description": "Firearm Item code; a non-firearm returns an empty list with is_firearm=False rather than erroring."
                  }
                },
                "required": [
                  "item_code"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_core.api.counter_pickup.open_pickup_invoice": {
      "post": {
        "tags": [
          "ffl_core"
        ],
        "summary": "Open (or return) the DRAFT POS Invoice that hands over a counter pickup's",
        "description": "firearm(s) — the Pending Order page's Pickup button on a counter row.\n\n**Auth (derived from code):** Roles: Sales User / Sales Manager / Stock Manager / System Manager\n\n**Permissions:** Sales User / Sales Manager / Stock Manager / System Manager.\n\nSource: `apps/ffl_core/ffl_core/api/counter_pickup.py:123`",
        "operationId": "ffl_core.api.counter_pickup.open_pickup_invoice",
        "responses": {
          "200": {
            "description": "{\"ok\": True, \"pos_invoice\": name, \"already\": bool}.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "sales_invoice": {
                    "type": "string",
                    "description": "Submitted counter-order Sales Invoice with ``ffl_pickup_in_store`` set and an arrived, undisposed gun."
                  }
                },
                "required": [
                  "sales_invoice"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_core.api.crm.add_want": {
      "post": {
        "tags": [
          "ffl_core"
        ],
        "summary": "Add a want to a deal's primary contact: when stock that fits arrives, you get a task.",
        "description": "**Auth (derived from code):** Roles: Sales User / Sales Manager / System Manager\n\nSource: `apps/ffl_core/ffl_core/api/crm.py:235`",
        "operationId": "ffl_core.api.crm.add_want",
        "responses": {
          "200": {
            "description": "str: The CRM Want's name. The owner is the caller. Refused for a deal with no contact, and when neither keywords nor an item is given.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "deal": {
                    "type": "string",
                    "description": "The CRM Deal's name."
                  },
                  "keywords": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "description": "What they are after, for example \"P228\" or \"Mosin 91/30\". Every word must appear in the arriving gun's name, brand, model, caliber or description."
                  },
                  "item": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "description": "An Item to alert on, instead of or as well as keywords."
                  },
                  "budget": {
                    "type": [
                      "number",
                      "null"
                    ],
                    "description": "What they want to spend. Shown on the task; arrivals are not filtered by price."
                  },
                  "notes": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "description": "Anything else worth knowing."
                  }
                },
                "required": [
                  "deal"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_core.api.crm.check_sale": {
      "post": {
        "tags": [
          "ffl_core"
        ],
        "summary": "Before a POS / Sales Invoice is saved: the guns on it held for a deal whose customer is not this",
        "description": "sale's.\n\n**Auth (derived from code):** Roles: Sales User / Sales Manager / Stock Manager / System Manager / Accounts User / Accounts Manager\n\nSource: `apps/ffl_core/ffl_core/api/crm.py:523`",
        "operationId": "ffl_core.api.crm.check_sale",
        "responses": {
          "200": {
            "description": "dict: {\"blocked\": [{\"serial\", \"hold\", \"deal\", \"customer\", \"customer_name\", \"expires_at\", \"expires_label\", \"held_by\", \"held_by_name\", \"message\"}], \"self_approves\": the caller is a manager, \"approvers\": [{\"user\", \"full_name\", \"has_pin\", \"pin_off\"}] when something is blocked}.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "doc": {
                    "description": "The form's document (POS Invoice or Sales Invoice) as JSON."
                  }
                },
                "required": [
                  "doc"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_core.api.crm.connect_my_mailbox": {
      "post": {
        "tags": [
          "ffl_core"
        ],
        "summary": "Start connecting your own mailbox to the POS: the address of the provider's sign-in page.",
        "description": "For a staff member whose mailbox an administrator set up as an OAuth Email Account with them as\nits connected user; they sign in to their own mail account, not the administrator. Frappe's own\nAuthorize button needs read access to the Connected App, which staff do not have.\n\n**Auth (derived from code):** Roles: Sales User / Sales Manager / System Manager\n\nSource: `apps/ffl_core/ffl_core/api/crm.py:47`",
        "operationId": "ffl_core.api.crm.connect_my_mailbox",
        "responses": {
          "200": {
            "description": "str: The sign-in address to open. Refused for an Email Account whose connected user is someone else, or that does not sign in with OAuth.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "email_account": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "description": "The Email Account to connect. Optional when you have only one."
                  },
                  "success_uri": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "description": "Where to land after signing in (a path on this site). Default: CRM."
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_core.api.crm.crm_list_data": {
      "post": {
        "tags": [
          "ffl_core"
        ],
        "summary": "CRM's list data for its Leads and Deals pages (hooks.py overrides ``crm.api.doc.get_data``), with",
        "description": "three changes: a Leads list leaves out other mail unless it filters on the status or category,\n``@me`` inside a filter's list of values is the caller (CRM's page replaces only a plain ``@me``, and\n**My follow-ups** asks for \"mine or nobody's\"), and a Deals list on CRM's own columns shows the\nperson's name first.\n\n**Auth (derived from code):** Any authenticated user — no explicit role gate at function entry (deliberate open reads document this in Permissions).\n\nSource: `apps/ffl_core/ffl_core/api/crm.py:266`",
        "operationId": "ffl_core.api.crm.crm_list_data",
        "responses": {
          "200": {
            "description": "dict: CRM's answer: the rows and columns of the list.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        }
      }
    },
    "/api/method/ffl_core.api.crm.deal_customer_summary": {
      "post": {
        "tags": [
          "ffl_core"
        ],
        "summary": "What the Deal page's customer card shows. Never carries an ID number, date of birth, 4473 or",
        "description": "NICS.\n\n**Auth (derived from code):** Roles: Sales User / Sales Manager / System Manager\n\nSource: `apps/ffl_core/ffl_core/api/crm.py:114`",
        "operationId": "ffl_core.api.crm.deal_customer_summary",
        "responses": {
          "200": {
            "description": "dict: {\"customer\": None, \"matches\": [...], \"html\"} before the deal has a customer, else {\"customer\", \"customer_name\", \"flags\": {\"status\", \"status_reason\", \"banned\", \"override_until\", \"alerts\", \"tags\"}, \"ffl\": {\"is_dealer\", \"on_file\", \"expiry_date\", \"expired\"}, \"orders\": last orders, \"open_orders\": orders on Pending Order, \"lifetime_spend\": Net Sales as the Sales Report reads it, \"holds\": guns held for the deal [{\"serial\", \"expires_label\"}], \"marketing\": {\"status\", \"tags\"} of the customer's marketing contact or None, \"html\"}. Refused while the switch is off.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "deal": {
                    "type": "string",
                    "description": "The CRM Deal's name."
                  }
                },
                "required": [
                  "deal"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_core.api.crm.deal_holds": {
      "post": {
        "tags": [
          "ffl_core"
        ],
        "summary": "The Deal page's Hold guns dialog: each gun on the deal's lines, its hold and what can be done.",
        "description": "Answers while Hold guns for deals is off too, so holds still running stay in view.\n\n**Auth (derived from code):** Roles: Sales User / Sales Manager / System Manager\n\nSource: `apps/ffl_core/ffl_core/api/crm.py:407`",
        "operationId": "ffl_core.api.crm.deal_holds",
        "responses": {
          "200": {
            "description": "dict: {\"guns\": [{\"serial\", \"item_code\", \"item_name\", \"hold\": None or {\"name\", \"expires_at\", \"expires_label\", \"held_by\", \"held_by_name\", \"extensions\", \"extend_needs_manager\", \"release_needs_manager\"}, \"blocked\": why it cannot be held or None, \"needs_manager\": holding it takes a manager}], \"enabled\": whether new holds are on, \"self_approves\": the caller is a manager, \"approvers\": [{\"user\", \"full_name\", \"has_pin\", \"pin_off\"}] otherwise}.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "deal": {
                    "type": "string",
                    "description": "The CRM Deal's name."
                  }
                },
                "required": [
                  "deal"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_core.api.crm.deals_use_no_quotes": {
      "post": {
        "tags": [
          "ffl_core"
        ],
        "summary": "Stands in for CRM's quotation gates (hooks.py): the Deal page shows no Quotations tab and no",
        "description": "**Create Quotation** button, since a deal closes through **Open order**.\n\n**Auth (derived from code):** Any authenticated user — no explicit role gate at function entry (deliberate open reads document this in Permissions).\n\nSource: `apps/ffl_core/ffl_core/api/crm.py:310`",
        "operationId": "ffl_core.api.crm.deals_use_no_quotes",
        "responses": {
          "200": {
            "description": "bool: Always False.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "boolean"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        }
      }
    },
    "/api/method/ffl_core.api.crm.draft_reply": {
      "post": {
        "tags": [
          "ffl_core"
        ],
        "summary": "A draft reply to the customer's message, written by an extension, or the one it wrote when the mail",
        "description": "arrived while that still holds. Nothing is sent or saved.\n\n**Auth (derived from code):** Roles: Sales User / Sales Manager / System Manager\n\nSource: `apps/ffl_core/ffl_core/api/crm.py:593`",
        "operationId": "ffl_core.api.crm.draft_reply",
        "responses": {
          "200": {
            "description": "dict: {\"native_ok\": 1 when the draft goes into that composer, \"to\", \"subject\", \"sender\", \"in_reply_to\": the Communication answered, \"channel\": \"email\" or \"gunbroker\", \"content_html\", \"signature_html\", \"handoff\": what needs a person, or None}. The envelope fields are for the page's own dialog when the composer is not used. Refused when the record has nothing from the customer to answer, or with the extension's own reason.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "doctype": {
                    "type": "string",
                    "description": "\"CRM Lead\" or \"CRM Deal\"."
                  },
                  "name": {
                    "type": "string",
                    "description": "The record's name."
                  },
                  "quote_text": {
                    "type": "string",
                    "description": "The text of the quote in CRM's open composer (the mail Reply was clicked on), if any.",
                    "default": ""
                  },
                  "composer": {
                    "type": "integer",
                    "description": "1 when CRM's composer is open.",
                    "default": 0
                  }
                },
                "required": [
                  "doctype",
                  "name"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_core.api.crm.ensure_deal_customer": {
      "post": {
        "tags": [
          "ffl_core"
        ],
        "summary": "The deal's POS customer: its link, the matches to confirm, or a new customer on confirm.",
        "description": "**Auth (derived from code):** Roles: Sales User / Sales Manager / System Manager\n\nSource: `apps/ffl_core/ffl_core/api/crm.py:135`",
        "operationId": "ffl_core.api.crm.ensure_deal_customer",
        "responses": {
          "200": {
            "description": "dict: {\"customer\": name} once there is one; else {\"customer\": None, \"matches\": [{\"name\", \"customer_name\", \"customer_status\", \"matched\", \"banned\", \"status_reason\", \"alerts\"}], \"new\": the values a new customer would take, \"html\": the dialog's text}.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "deal": {
                    "type": "string",
                    "description": "The CRM Deal's name."
                  },
                  "customer": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "description": "The Customer the employee confirmed: it goes on the deal and on its contact."
                  },
                  "create": {
                    "type": "integer",
                    "description": "1 to make a new Customer from the deal's contact.",
                    "default": 0
                  }
                },
                "required": [
                  "deal"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_core.api.crm.extend_hold": {
      "post": {
        "tags": [
          "ffl_core"
        ],
        "summary": "Another 48 hours on a hold. The person who placed it extends it once; after that, or for anyone",
        "description": "else, a manager does (signed in, or picked with their PIN).\n\n**Auth (derived from code):** Roles: Sales User / Sales Manager / System Manager\n\nSource: `apps/ffl_core/ffl_core/api/crm.py:458`",
        "operationId": "ffl_core.api.crm.extend_hold",
        "responses": {
          "200": {
            "description": "dict: The hold: {\"name\", \"serial\", \"deal\", \"status\", \"expires_at\", \"expires_label\", \"held_by\", \"extensions\", \"end_reason\"}.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "hold": {
                    "type": "string",
                    "description": "The CRM Deal Hold's name."
                  },
                  "approver": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "description": "The manager approving."
                  },
                  "pin": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "description": "The approver's counter PIN."
                  },
                  "password": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "description": "Or their password."
                  }
                },
                "required": [
                  "hold"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_core.api.crm.hold_guns": {
      "post": {
        "tags": [
          "ffl_core"
        ],
        "summary": "Hold guns on a deal (for 48 hours unless told otherwise): only the deal's customer can buy them meanwhile, at the",
        "description": "counter and on the website. Each gun is judged on its own.\n\n**Auth (derived from code):** Roles: Sales User / Sales Manager / System Manager\n\nSource: `apps/ffl_core/ffl_core/api/crm.py:426`",
        "operationId": "ffl_core.api.crm.hold_guns",
        "responses": {
          "200": {
            "description": "dict: {\"held\": [{\"name\", \"serial\", \"deal\", \"status\", \"expires_at\", \"expires_label\", \"held_by\", \"extensions\", \"end_reason\"}], \"refused\": [{\"serial\", \"reason\", \"needs_manager\"?}]}. Refused while Hold guns for deals is off.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "deal": {
                    "type": "string",
                    "description": "The CRM Deal's name. It needs its POS customer."
                  },
                  "serials": {
                    "description": "The guns' serial numbers (a list, or JSON). One that is not on the deal's lines yet and is in stock goes on first: on the line of its item that names no gun, else on a line of its own."
                  },
                  "approver": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "description": "The manager approving, when a gun needs one (held for this deal before)."
                  },
                  "pin": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "description": "The approver's counter PIN."
                  },
                  "password": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "description": "Or their password."
                  },
                  "hours": {
                    "type": [
                      "integer",
                      "null"
                    ],
                    "description": "How long: 24, 48, 72 or 168. 48 when not given."
                  }
                },
                "required": [
                  "deal",
                  "serials"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_core.api.crm.make_lead_from_mail": {
      "post": {
        "tags": [
          "ffl_core"
        ],
        "summary": "Make the lead for a mail the AI screening judged not to be from a customer.",
        "description": "The mail goes by the normal mail rules with the screening skipped: a new lead shared with the team,\nor the sender's deal if they have become a customer.\n\n**Auth (derived from code):** Roles: Sales User / Sales Manager / System Manager\n\nSource: `apps/ffl_core/ffl_core/api/crm.py:82`",
        "operationId": "ffl_core.api.crm.make_lead_from_mail",
        "responses": {
          "200": {
            "description": "dict: {\"doctype\": \"CRM Lead\" or \"CRM Deal\", \"name\": its name} (open it at /crm/leads/<name> or /crm/deals/<name>). Refused for a mail that is already linked, was not screened out, or is not received mail.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "communication": {
                    "type": "string",
                    "description": "The Communication's name."
                  }
                },
                "required": [
                  "communication"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_core.api.crm.make_sell_offer": {
      "post": {
        "tags": [
          "ffl_core"
        ],
        "summary": "Store what the store offers for a gun someone sells it. No email is sent, and the amount never",
        "description": "counts as a sale (the deal's value).\n\n**Auth (derived from code):** Roles: Sales User / Sales Manager / System Manager\n\nSource: `apps/ffl_core/ffl_core/api/crm.py:187`",
        "operationId": "ffl_core.api.crm.make_sell_offer",
        "responses": {
          "200": {
            "description": "dict: The Gun offered card, as sell_request_card.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "deal": {
                    "type": "string",
                    "description": "The CRM Deal's name, an open sell request whose gun is not received yet."
                  },
                  "amount": {
                    "type": "number",
                    "description": "The offer, more than 0."
                  }
                },
                "required": [
                  "deal",
                  "amount"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_core.api.crm.matches_card": {
      "post": {
        "tags": [
          "ffl_core"
        ],
        "summary": "The Matches card of a Lead or Deal page: what the store has for this customer, priced as the",
        "description": "register prices it now.\n\n**Auth (derived from code):** Roles: Sales User / Sales Manager / System Manager\n\nSource: `apps/ffl_core/ffl_core/api/crm.py:679`",
        "operationId": "ffl_core.api.crm.matches_card",
        "responses": {
          "200": {
            "description": "dict: {\"shown\": there is something to show, \"html\", \"guns\": on a deal, the matched guns not on it yet that can be held now ([{\"serial\", \"label\"}])}.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "doctype": {
                    "type": "string",
                    "description": "\"CRM Lead\" or \"CRM Deal\"."
                  },
                  "name": {
                    "type": "string",
                    "description": "The record's name."
                  }
                },
                "required": [
                  "doctype",
                  "name"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_core.api.crm.memory_card": {
      "post": {
        "tags": [
          "ffl_core"
        ],
        "summary": "The Memory card of a Lead or Deal page: what the customer told the store, and the record's summary.",
        "description": "**Auth (derived from code):** Roles: Sales User / Sales Manager / System Manager\n\nSource: `apps/ffl_core/ffl_core/api/crm.py:659`",
        "operationId": "ffl_core.api.crm.memory_card",
        "responses": {
          "200": {
            "description": "dict: {\"html\", \"shown\": the page shows the card (memory is on, or something is kept), \"ready\": an extension updates memory (Update memory shows), \"can_edit\": you may change this record, \"has_content\", \"values\": {\"want\", \"trade_in\", \"preference\", \"question\" (one row a line), \"budget\", \"state\", \"auto_update\"} for Edit memory}.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "doctype": {
                    "type": "string",
                    "description": "\"CRM Lead\" or \"CRM Deal\"."
                  },
                  "name": {
                    "type": "string",
                    "description": "The record's name."
                  }
                },
                "required": [
                  "doctype",
                  "name"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_core.api.crm.memory_clear": {
      "post": {
        "tags": [
          "ffl_core"
        ],
        "summary": "Clear memory: every row of the customer's memory you can see goes, and the summary of each of their",
        "description": "leads and deals you may change. On a lead that became a deal, the deal's rights apply.\n\n**Auth (derived from code):** Roles: Sales User / Sales Manager / System Manager\n\nSource: `apps/ffl_core/ffl_core/api/crm.py:738`",
        "operationId": "ffl_core.api.crm.memory_clear",
        "responses": {
          "200": {
            "description": "dict: The new card, as memory_card returns it, with \"summaries_cleared\" and \"summaries_kept\" (the person's other leads and deals you may not change keep theirs).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "doctype": {
                    "type": "string",
                    "description": "\"CRM Lead\" or \"CRM Deal\"."
                  },
                  "name": {
                    "type": "string",
                    "description": "The record's name."
                  }
                },
                "required": [
                  "doctype",
                  "name"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_core.api.crm.memory_save": {
      "post": {
        "tags": [
          "ffl_core"
        ],
        "summary": "Edit memory: save what the customer's memory says. A new or changed row is yours and the AI leaves",
        "description": "it alone.\n\n**Auth (derived from code):** Roles: Sales User / Sales Manager / System Manager\n\nSource: `apps/ffl_core/ffl_core/api/crm.py:717`",
        "operationId": "ffl_core.api.crm.memory_save",
        "responses": {
          "200": {
            "description": "dict: The new card, as memory_card returns it. Refused with ID numbers, eligibility details, prices or stock in a row, a state that is not a US state, or more lines than a kind keeps.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "doctype": {
                    "type": "string",
                    "description": "\"CRM Lead\" or \"CRM Deal\"."
                  },
                  "name": {
                    "type": "string",
                    "description": "The record's name."
                  },
                  "values": {
                    "description": "{\"want\", \"trade_in\", \"preference\", \"question\" (one row a line), \"budget\", \"state\", \"auto_update\"}, as a dict or JSON."
                  }
                },
                "required": [
                  "doctype",
                  "name",
                  "values"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_core.api.crm.memory_source": {
      "post": {
        "tags": [
          "ffl_core"
        ],
        "summary": "The customer message a row of the Memory card came from (its \"said\" link).",
        "description": "**Auth (derived from code):** Roles: Sales User / Sales Manager / System Manager\n\nSource: `apps/ffl_core/ffl_core/api/crm.py:698`",
        "operationId": "ffl_core.api.crm.memory_source",
        "responses": {
          "200": {
            "description": "dict: {\"subject\", \"at\", \"text\": plain text, 2000 characters at most}. Refused for a row that is not this customer's, or a message on a record you may not read.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "doctype": {
                    "type": "string",
                    "description": "\"CRM Lead\" or \"CRM Deal\"."
                  },
                  "name": {
                    "type": "string",
                    "description": "The record's name."
                  },
                  "row": {
                    "type": "string",
                    "description": "The memory row's name, from the card."
                  }
                },
                "required": [
                  "doctype",
                  "name",
                  "row"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_core.api.crm.memory_update_now": {
      "post": {
        "tags": [
          "ffl_core"
        ],
        "summary": "Update memory: have the extension read the record's latest customer messages now.",
        "description": "**Auth (derived from code):** Roles: Sales User / Sales Manager / System Manager\n\nSource: `apps/ffl_core/ffl_core/api/crm.py:757`",
        "operationId": "ffl_core.api.crm.memory_update_now",
        "responses": {
          "200": {
            "description": "dict: The new card, as memory_card returns it. Refused while memory is off, with the extension's own reason (for example a spending limit), or when nothing could be updated.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "doctype": {
                    "type": "string",
                    "description": "\"CRM Lead\" or \"CRM Deal\"."
                  },
                  "name": {
                    "type": "string",
                    "description": "The record's name."
                  }
                },
                "required": [
                  "doctype",
                  "name"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_core.api.crm.open_deal": {
      "post": {
        "tags": [
          "ffl_core"
        ],
        "summary": "The contact's open deal, made when they have none, to write to them from CRM.",
        "description": "**Auth (derived from code):** Roles: Sales User / Sales Manager / System Manager\n\nSource: `apps/ffl_core/ffl_core/api/crm.py:25`",
        "operationId": "ffl_core.api.crm.open_deal",
        "responses": {
          "200": {
            "description": "str: The CRM Deal's name (open it at /crm/deals/<name>#emails). Refused for a contact without an email address.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "contact": {
                    "type": "string",
                    "description": "The Contact's name."
                  }
                },
                "required": [
                  "contact"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_core.api.crm.open_deal_order": {
      "post": {
        "tags": [
          "ffl_core"
        ],
        "summary": "Save a deal with a customer as a Create Order draft, to finish the sale on that page.",
        "description": "**Auth (derived from code):** Roles: Sales User / Sales Manager / System Manager\n\nSource: `apps/ffl_core/ffl_core/api/crm.py:154`",
        "operationId": "ffl_core.api.crm.open_deal_order",
        "responses": {
          "200": {
            "description": "dict: {\"draft\": the draft's name, \"route\": the page to open, \"skipped\": deal lines that are not POS items}. The page sets the prices, as for a line picked there.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "deal": {
                    "type": "string",
                    "description": "The CRM Deal's name."
                  }
                },
                "required": [
                  "deal"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_core.api.crm.override_hold": {
      "post": {
        "tags": [
          "ffl_core"
        ],
        "summary": "A manager ends a deal's hold at the counter so the gun can be sold to someone else; the deal's",
        "description": "owner gets a task. A manager signed in approves their own; anyone else names one, who types their\ncounter PIN (or password).\n\n**Auth (derived from code):** Roles: Sales User / Sales Manager / Stock Manager / System Manager\n\nSource: `apps/ffl_core/ffl_core/api/crm.py:549`",
        "operationId": "ffl_core.api.crm.override_hold",
        "responses": {
          "200": {
            "description": "dict: {\"released\": the hold, now Released, or None when nothing held the gun, \"task\": the CRM Task given to the deal owner, or None}.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "serial": {
                    "type": "string",
                    "description": "The held gun's Serial No."
                  },
                  "reason": {
                    "type": "string",
                    "description": "Why (required)."
                  },
                  "approver": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "description": "The manager approving."
                  },
                  "pin": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "description": "The approver's counter PIN."
                  },
                  "password": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "description": "Or their password."
                  }
                },
                "required": [
                  "serial",
                  "reason"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_core.api.crm.price_options": {
      "post": {
        "tags": [
          "ffl_core"
        ],
        "summary": "The products Insert price offers on a Lead or Deal, most relevant first, at the register's price.",
        "description": "**Auth (derived from code):** Roles: Sales User / Sales Manager / System Manager\n\nSource: `apps/ffl_core/ffl_core/api/crm.py:617`",
        "operationId": "ffl_core.api.crm.price_options",
        "responses": {
          "200": {
            "description": "dict: {\"options\": [{\"item_code\", \"serial_no\", \"label\"}] (15 at most), \"default\": 0}.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "doctype": {
                    "type": "string",
                    "description": "\"CRM Lead\" or \"CRM Deal\"."
                  },
                  "name": {
                    "type": "string",
                    "description": "The record's name."
                  }
                },
                "required": [
                  "doctype",
                  "name"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_core.api.crm.price_text": {
      "post": {
        "tags": [
          "ffl_core"
        ],
        "summary": "The line Insert price puts in the reply, priced now.",
        "description": "**Auth (derived from code):** Roles: Sales User / Sales Manager / System Manager\n\nSource: `apps/ffl_core/ffl_core/api/crm.py:634`",
        "operationId": "ffl_core.api.crm.price_text",
        "responses": {
          "200": {
            "description": "dict: {\"text\": \"{product} — ${price}\"}. Refused when the Item has no price.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "doctype": {
                    "type": "string",
                    "description": "\"CRM Lead\" or \"CRM Deal\"."
                  },
                  "name": {
                    "type": "string",
                    "description": "The record's name."
                  },
                  "item_code": {
                    "type": "string",
                    "description": "The Item."
                  },
                  "serial_no": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "description": "The gun, for a model priced gun by gun; it must be one of the Item's in stock."
                  }
                },
                "required": [
                  "doctype",
                  "name",
                  "item_code"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_core.api.crm.release_hold": {
      "post": {
        "tags": [
          "ffl_core"
        ],
        "summary": "End a hold: the gun is for sale to anyone again. Whoever placed it, the deal owner or a manager;",
        "description": "anyone else with a manager's PIN.\n\n**Auth (derived from code):** Roles: Sales User / Sales Manager / System Manager\n\nSource: `apps/ffl_core/ffl_core/api/crm.py:479`",
        "operationId": "ffl_core.api.crm.release_hold",
        "responses": {
          "200": {
            "description": "dict: The hold, now Released: {\"name\", \"serial\", \"deal\", \"status\", \"expires_at\", \"expires_label\", \"held_by\", \"extensions\", \"end_reason\"}.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "hold": {
                    "type": "string",
                    "description": "The CRM Deal Hold's name."
                  },
                  "reason": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "description": "Why (optional)."
                  },
                  "approver": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "description": "The manager approving."
                  },
                  "pin": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "description": "The approver's counter PIN."
                  },
                  "password": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "description": "Or their password."
                  }
                },
                "required": [
                  "hold"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_core.api.crm.reply_draft_ready": {
      "post": {
        "tags": [
          "ffl_core"
        ],
        "summary": "Which of a Lead or Deal page's Draft reply and Insert price buttons show. No network call.",
        "description": "**Auth (derived from code):** Roles: Sales User / Sales Manager / System Manager\n\nSource: `apps/ffl_core/ffl_core/api/crm.py:574`",
        "operationId": "ffl_core.api.crm.reply_draft_ready",
        "responses": {
          "200": {
            "description": "dict: {\"ready\": an extension drafts replies, \"insert_price\": linking deals to POS orders is on, \"draft_ready\": a reply drafted when the mail arrived is waiting for the caller}. All false on a sell request.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "doctype": {
                    "type": "string",
                    "description": "\"CRM Lead\" or \"CRM Deal\"."
                  },
                  "name": {
                    "type": "string",
                    "description": "The record's name."
                  }
                },
                "required": [
                  "doctype",
                  "name"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_core.api.crm.reply_queue": {
      "post": {
        "tags": [
          "ffl_core"
        ],
        "summary": "Your own reply queue: the customers on your CRM leads and deals who wait for an answer, longest first.",
        "description": "The same rows as the daily reply list, for the records you own.\n\n**Auth (derived from code):** Roles: Sales User / Sales Manager / System Manager\n\nSource: `apps/ffl_core/ffl_core/api/crm.py:775`",
        "operationId": "ffl_core.api.crm.reply_queue",
        "responses": {
          "200": {
            "description": "list: One dict per record: \"doctype\", \"name\", \"link\" (the CRM page's path), \"customer\", \"owner\", \"subject\" and \"received\" of the waiting message, \"days\" waiting, \"messages\" from the customer since the store's last mail, \"tasks\" (open task titles) and \"summary\". A record kept in the list only by an open task has no \"subject\", \"received\" or \"days\".",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "array"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        }
      }
    },
    "/api/method/ffl_core.api.crm.sell_gun_intake": {
      "post": {
        "tags": [
          "ffl_core"
        ],
        "summary": "What the register's Trade-in dialog is filled with to receive a sell request's gun. Writes",
        "description": "nothing: staff check the gun and submit the dialog, and that books it.\n\n**Auth (derived from code):** Roles: Sales User / Sales Manager / System Manager\n\nSource: `apps/ffl_core/ffl_core/api/crm.py:218`",
        "operationId": "ffl_core.api.crm.sell_gun_intake",
        "responses": {
          "200": {
            "description": "dict: {\"deal\", \"source_name\": the seller (the deal's customer), \"manufacturer\", \"model_name\", \"caliber\", \"firearm_type\", \"serial_no\", \"acquisition_cost\": the offer or None}. No condition: staff grade the gun after inspecting it.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "deal": {
                    "type": "string",
                    "description": "The CRM Deal's name, an open sell request with a customer and no gun received yet."
                  }
                },
                "required": [
                  "deal"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_core.api.crm.sell_offer_accepted": {
      "post": {
        "tags": [
          "ffl_core"
        ],
        "summary": "The seller accepted the offer: the deal waits for the gun from today. A second call keeps the",
        "description": "first day.\n\n**Auth (derived from code):** Roles: Sales User / Sales Manager / System Manager\n\nSource: `apps/ffl_core/ffl_core/api/crm.py:203`",
        "operationId": "ffl_core.api.crm.sell_offer_accepted",
        "responses": {
          "200": {
            "description": "dict: The Gun offered card, as sell_request_card.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "deal": {
                    "type": "string",
                    "description": "The CRM Deal's name, an open sell request with an offer."
                  }
                },
                "required": [
                  "deal"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_core.api.crm.sell_request_card": {
      "post": {
        "tags": [
          "ffl_core"
        ],
        "summary": "What a sell request's Gun offered card shows: the gun, its photos and where the buy stands.",
        "description": "**Auth (derived from code):** Roles: Sales User / Sales Manager / System Manager\n\nSource: `apps/ffl_core/ffl_core/api/crm.py:169`",
        "operationId": "ffl_core.api.crm.sell_request_card",
        "responses": {
          "200": {
            "description": "dict: {\"html\", \"offer\": the store's offer or 0, \"accepted_on\": the day the seller accepted or None, \"received\": the gun is received}. Refused while the switch is off.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "deal": {
                    "type": "string",
                    "description": "The CRM Deal's name, a sell request."
                  }
                },
                "required": [
                  "deal"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_core.api.crm.serial_hold": {
      "post": {
        "tags": [
          "ffl_core"
        ],
        "summary": "The live deal hold on one gun, for the counter. Carries no ID, 4473 or NICS data.",
        "description": "**Auth (derived from code):** Roles: Sales User / Sales Manager / Stock Manager / System Manager\n\nSource: `apps/ffl_core/ffl_core/api/crm.py:502`",
        "operationId": "ffl_core.api.crm.serial_hold",
        "responses": {
          "200": {
            "description": "dict: {\"hold\": None or {\"serial\", \"hold\", \"deal\", \"customer\", \"customer_name\", \"expires_at\", \"expires_label\", \"held_by\", \"held_by_name\", \"message\"}, \"self_approves\": the caller is a manager, \"approvers\": [{\"user\", \"full_name\", \"has_pin\", \"pin_off\"}] otherwise}.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "serial": {
                    "type": "string",
                    "description": "The Serial No."
                  }
                },
                "required": [
                  "serial"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_core.api.extensions.disable_notice": {
      "get": {
        "tags": [
          "ffl_core"
        ],
        "summary": "What turning this extension off will interrupt, in the extension's own words.",
        "description": "**Auth (derived from code):** Roles: System Manager\n\nSource: `apps/ffl_core/ffl_core/api/extensions.py:125`",
        "operationId": "ffl_core.api.extensions.disable_notice",
        "responses": {
          "200": {
            "description": "str: one sentence from the manifest's ``disable_notice`` callable (dotted path), or \"\" when the extension declares none — the page then flips the switch without a dialog."
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "parameters": [
          {
            "name": "extension",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "POS Extension id."
          }
        ]
      }
    },
    "/api/method/ffl_core.api.extensions.fetch_update": {
      "post": {
        "tags": [
          "ffl_core"
        ],
        "summary": "Download the newer version the update service offers for an extension",
        "description": "(the page's Update button), check it, and describe it like an upload.\n\nThe package must be what the service announced (``latest_sha256`` from\nextensions/updates.check), for this extension and version, and this POS\nmust be able to run it, and it must come from the publisher of the one\ninstalled (an id clash with a sideloaded fork is not an update);\n``install_upload(sha256, id)`` then upgrades.\n\n**Auth (derived from code):** Roles: System Manager\n\nSource: `apps/ffl_core/ffl_core/api/extensions.py:405`",
        "operationId": "ffl_core.api.extensions.fetch_update",
        "responses": {
          "200": {
            "description": "dict: the ``inspect_upload`` shape (``filename`` is ``<id>-<version>.zip``) plus ``source``: {\"type\": \"update-service\", \"version\"}."
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "extension": {
                    "type": "string",
                    "description": "POS Extension id."
                  }
                },
                "required": [
                  "extension"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_core.api.extensions.inspect_git": {
      "post": {
        "tags": [
          "ffl_core"
        ],
        "summary": "Clone a public git repository at a branch or tag, lint it, and describe it like an upload.",
        "description": "The clone is shallow, over https only, with no credentials, and gives up\nafter 60 seconds; a private repository fails at once (download its zip\nand upload that instead). The tree is packed into an upload by its sha256,\nexactly as ``inspect_upload`` keeps a zip — ``install_upload`` installs or\nupgrades it.\n\n**Auth (derived from code):** Roles: System Manager\n\nSource: `apps/ffl_core/ffl_core/api/extensions.py:378`",
        "operationId": "ffl_core.api.extensions.inspect_git",
        "responses": {
          "200": {
            "description": "dict: the ``inspect_upload`` shape (``filename`` is ``<url>@<ref>``) plus ``source``: {\"type\": \"git\", \"url\", \"ref\", \"commit\"}."
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "url": {
                    "type": "string",
                    "description": "https://<host>/<owner>/<repo>[.git] of a public repository."
                  },
                  "ref": {
                    "type": "string",
                    "description": "branch or tag name."
                  }
                },
                "required": [
                  "url",
                  "ref"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_core.api.extensions.inspect_upload": {
      "post": {
        "tags": [
          "ffl_core"
        ],
        "summary": "Take an uploaded extension zip (multipart field ``file``), lint it, and describe it.",
        "description": "Nothing is installed: the zip is kept under the site's private files by\nits sha256 until ``install_upload`` is called or it is replaced.\n\n**Auth (derived from code):** Roles: System Manager\n\nSource: `apps/ffl_core/ffl_core/api/extensions.py:343`",
        "operationId": "ffl_core.api.extensions.inspect_upload",
        "responses": {
          "200": {
            "description": "dict: the lint report (``ok``, ``findings``, ``permissions``, ``app_id``, ``title``, ``version``, ``publisher``…) plus ``sha256``, ``high_risk``, ``on_bench`` / ``installed_on_site`` / ``baked`` for that id, and ``upgrade``: None when the id is not on this server, else {\"from\", \"to\", \"allowed\", \"reason\", \"permissions_added\", \"permissions_removed\", \"release_notes\"} (the package's notes for versions after ``from`` up to ``to``, newest first, as one markdown text). An id whose last upgrade did not finish is not allowed until it is rolled back; ``reason`` says so."
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        }
      }
    },
    "/api/method/ffl_core.api.extensions.install_on_site": {
      "post": {
        "tags": [
          "ffl_core"
        ],
        "summary": "Install an extension that is on the bench but not on this site (background job).",
        "description": "**Auth (derived from code):** Roles: System Manager\n\nSource: `apps/ffl_core/ffl_core/api/extensions.py:210`",
        "operationId": "ffl_core.api.extensions.install_on_site",
        "responses": {
          "200": {
            "description": "dict: {\"extension\": id, \"job_state\": \"Installing\"} — poll list_extensions."
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "extension": {
                    "type": "string",
                    "description": "POS Extension id."
                  }
                },
                "required": [
                  "extension"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_core.api.extensions.install_upload": {
      "post": {
        "tags": [
          "ffl_core"
        ],
        "summary": "Stage an inspected upload and hand it to the store's agent (background job).",
        "description": "**Auth (derived from code):** Roles: System Manager\n\nSource: `apps/ffl_core/ffl_core/api/extensions.py:471`",
        "operationId": "ffl_core.api.extensions.install_upload",
        "responses": {
          "200": {
            "description": "dict: {\"extension\": id, \"job_state\": \"Staging\", \"mode\": \"install\" | \"upgrade\"} — poll list_extensions. An install appears as Staged, then Installing once the agent restarts the store; an upgrade (the id is on this server and the package is a newer version from upload or git) as Staged, then Upgrading. A same-id package that may not upgrade it is refused with the reason, and nothing starts while another extension is being installed, upgraded or removed, or the store is waiting to restart."
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "sha256": {
                    "type": "string",
                    "description": "the upload reference returned by ``inspect_upload``."
                  },
                  "confirm_id": {
                    "type": "string",
                    "description": "must equal the extension id — the typed confirmation (\"you are installing unreviewed code\"). The page's Update sends it itself (the manager confirms in its dialog)."
                  }
                },
                "required": [
                  "sha256",
                  "confirm_id"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_core.api.extensions.list_extensions": {
      "get": {
        "tags": [
          "ffl_core"
        ],
        "summary": "The registry as the Extensions page shows it.",
        "description": "**Auth (derived from code):** Roles: System Manager\n\nSource: `apps/ffl_core/ffl_core/api/extensions.py:84`",
        "operationId": "ffl_core.api.extensions.list_extensions",
        "responses": {
          "200": {
            "description": "dict: {\"core_version\": str, \"extensions\": [row...], \"incompatible\": int, \"busy\": int, \"busy_states\": [str], \"restart\": {\"pending\": dict | None, \"done\": dict | None}, \"update_service\": bool} — each row is a POS Extension with ``permissions`` / ``manifest`` decoded, ``high_risk`` (the permissions the page paints red) and ``effective`` (bool: switched on AND installed here AND compatible — what the extension actually does; ``enabled`` is only the store's switch) and ``update`` (None, or {\"version\", \"compatible\", \"reason\", \"requires_core\"}: the newer version the update service offers). ``busy_states``: the job states that lock a row. ``update_service``: an update source is set up on this site (else no update is ever offered)."
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        }
      }
    },
    "/api/method/ffl_core.api.extensions.refresh": {
      "post": {
        "tags": [
          "ffl_core"
        ],
        "summary": "Re-read the bench and the site (ffl_core.extensions.registry.sync), ask the",
        "description": "update service what is newer (ffl_core.extensions.updates.check), then list.\n\n**Auth (derived from code):** Roles: System Manager\n\nSource: `apps/ffl_core/ffl_core/api/extensions.py:105`",
        "operationId": "ffl_core.api.extensions.refresh",
        "responses": {
          "200": {
            "description": "dict: same shape as list_extensions, plus ``sync`` — the sync summary ({\"created\": [...], \"updated\": [...], \"unchanged\": [...], \"removed\": [...], \"reset\": [...]} — ``reset`` lists rows whose stuck job was marked Failed) — and ``updates``: {\"checked\": bool, \"offered\": {id: version}, \"error\"?: True}."
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        }
      }
    },
    "/api/method/ffl_core.api.extensions.release_notes": {
      "get": {
        "tags": [
          "ffl_core"
        ],
        "summary": "The extension's own release notes (its change_log folder), newest first.",
        "description": "**Auth (derived from code):** Roles: System Manager\n\nSource: `apps/ffl_core/ffl_core/api/extensions.py:269`",
        "operationId": "ffl_core.api.extensions.release_notes",
        "responses": {
          "200": {
            "description": "list: [[version, markdown], ...] — the same reader (and the same pre-release file-name rule) as the core's What's New; [] when the extension ships none."
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "parameters": [
          {
            "name": "extension",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "POS Extension id."
          }
        ]
      }
    },
    "/api/method/ffl_core.api.extensions.set_enabled": {
      "post": {
        "tags": [
          "ffl_core"
        ],
        "summary": "Turn an installed extension on or off for this store.",
        "description": "**Auth (derived from code):** Roles: System Manager\n\nSource: `apps/ffl_core/ffl_core/api/extensions.py:157`",
        "operationId": "ffl_core.api.extensions.set_enabled",
        "responses": {
          "200": {
            "description": "dict: the updated row (same shape as a list_extensions row)."
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "extension": {
                    "type": "string",
                    "description": "POS Extension id."
                  },
                  "enabled": {
                    "description": "1 to turn on, 0 to turn off."
                  }
                },
                "required": [
                  "extension",
                  "enabled"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_core.api.extensions.uninstall_from_site": {
      "post": {
        "tags": [
          "ffl_core"
        ],
        "summary": "Back up the database, then remove the extension from this site (background job).",
        "description": "The code stays on the bench (removing it is docs/self-hosting.md#extensions / the agent);\nthe extension's own before_uninstall hook cleans what it added to core.\n\n**Auth (derived from code):** Roles: System Manager\n\nSource: `apps/ffl_core/ffl_core/api/extensions.py:238`",
        "operationId": "ffl_core.api.extensions.uninstall_from_site",
        "responses": {
          "200": {
            "description": "dict: {\"extension\": id, \"job_state\": \"Uninstalling\"} — poll list_extensions."
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "extension": {
                    "type": "string",
                    "description": "POS Extension id."
                  },
                  "confirm_id": {
                    "type": "string",
                    "description": "must equal ``extension`` — the typed confirmation."
                  }
                },
                "required": [
                  "extension",
                  "confirm_id"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_core.api.extensions.uninstall_preview": {
      "get": {
        "tags": [
          "ffl_core"
        ],
        "summary": "What uninstalling removes from this site, so the confirmation can say so.",
        "description": "**Auth (derived from code):** Roles: System Manager\n\nSource: `apps/ffl_core/ffl_core/api/extensions.py:292`",
        "operationId": "ffl_core.api.extensions.uninstall_preview",
        "responses": {
          "200": {
            "description": "dict: {\"doctypes\": [{\"name\", \"rows\", \"child\"}], \"custom_fields\": int, \"roles\": [str], \"modules\": [str], \"records\": int, \"blocked\": bool} — every DocType of the app's modules (what remove_app drops) with row counts, the custom fields it added to core DocTypes, the roles it created, and ``blocked`` when any of its tables still hold records (then the only way out is turning it off — uninstall_from_site refuses)."
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "parameters": [
          {
            "name": "extension",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "POS Extension id."
          }
        ]
      }
    },
    "/api/method/ffl_core.api.extensions.upload_failure": {
      "get": {
        "tags": [
          "ffl_core"
        ],
        "summary": "Why a staged upload failed where no registry row says so (the page shows it after Install / Upgrade).",
        "description": "An install whose code never reached the registry has no row; an upgrade refused because the store\nwas busy, or because the id's last upgrade did not finish, leaves its row as it was.\n\n**Auth (derived from code):** Roles: System Manager\n\nSource: `apps/ffl_core/ffl_core/api/extensions.py:509`",
        "operationId": "ffl_core.api.extensions.upload_failure",
        "responses": {
          "200": {
            "description": "dict | None: {\"app\", \"message\"} or None."
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "parameters": [
          {
            "name": "sha256",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "the upload reference."
          }
        ]
      }
    },
    "/api/method/ffl_core.api.firearm_intake.lookup_serial": {
      "post": {
        "tags": [
          "ffl_core"
        ],
        "summary": "Look up a firearm by serial to short-circuit duplicate intakes.",
        "description": "Resolves via the canonical Serial No table first, then falls back to\nFFL Acquisition.serial in case the Item has been deleted.\n\n**Auth (derived from code):** Roles: Sales User / Sales Manager / Stock Manager / System Manager\n\nSource: `apps/ffl_core/ffl_core/api/firearm_intake.py:52`",
        "operationId": "ffl_core.api.firearm_intake.lookup_serial",
        "responses": {
          "200": {
            "description": "{found: false} — nothing on file; {found: true, source: \"erpnext\", item, acquisition} — already an Item (acquisition may be null); {found: true, source: \"acquisition_only\", acquisition} — an FFL Acquisition exists but its Item is gone.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "serial": {
                    "type": "string",
                    "description": "Serial number (whitespace-stripped; blank returns not-found)."
                  }
                },
                "required": [
                  "serial"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_core.api.gun_shop_cards.get_count": {
      "post": {
        "tags": [
          "ffl_core"
        ],
        "summary": "The number behind one \"Needs attention\" card on the Gun Shop home page.",
        "description": "**Auth (derived from code):** Roles: Desk User\n\nSource: `apps/ffl_core/ffl_core/api/gun_shop_cards.py:116`",
        "operationId": "ffl_core.api.gun_shop_cards.get_count",
        "responses": {
          "200": {
            "description": "``{\"value\": count, \"fieldtype\": \"Int\", \"route\": [...]}`` in the shape Frappe's custom Number Card expects; clicking the card opens ``route``. ``value`` is 0 for a user who may not open that page or report.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "filters": {
                    "description": "The card's ``filters_json`` (a JSON object or its string): ``{\"card\": <key>}`` with key one of pending_orders, pending_4473, transfer_pickups, to_receive, web_orders."
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_core.api.inventory_count.cancel_count": {
      "post": {
        "tags": [
          "ffl_core"
        ],
        "summary": "Cancel an open count without adjusting anything.",
        "description": "For a wrong start or an abandoned walk-through. The scans are kept for the record.\n\n**Auth (derived from code):** Roles: Stock Manager / System Manager\n\nSource: `apps/ffl_core/ffl_core/api/inventory_count.py:216`",
        "operationId": "ffl_core.api.inventory_count.cancel_count",
        "responses": {
          "200": {
            "description": "{ok}.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "count": {
                    "type": "string",
                    "description": "The Inventory Count name."
                  }
                },
                "required": [
                  "count"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_core.api.inventory_count.create_count": {
      "post": {
        "tags": [
          "ffl_core"
        ],
        "summary": "Start a stocktake.",
        "description": "With no warehouses and no item groups it covers the whole store: every\nwarehouse that holds the store's own stock, every item group. Anything outside\nthe scope never shows up as a difference.\n\n**Auth (derived from code):** Roles: Stock User / Stock Manager / System Manager\n\nSource: `apps/ffl_core/ffl_core/api/inventory_count.py:137`",
        "operationId": "ffl_core.api.inventory_count.create_count",
        "responses": {
          "200": {
            "description": "{name, company, warehouses: [name], item_groups: [name]}.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "company": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "description": "Company to count; defaults to the user's company."
                  },
                  "warehouses": {
                    "description": "Warehouse names (list or JSON) to limit the count to; empty = all."
                  },
                  "item_groups": {
                    "description": "Item Group names (list or JSON) to limit the count to (children included); empty = all."
                  },
                  "include_custody": {
                    "description": "1 to count customer-custody warehouses too, 0 to leave them out.",
                    "default": 1
                  },
                  "notes": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "description": "Optional free text."
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_core.api.inventory_count.finalize": {
      "post": {
        "tags": [
          "ffl_core"
        ],
        "summary": "Finalize a count: adjust the non-serialized differences and save the firearm report.",
        "description": "Posts one Stock Reconciliation for the non-serialized differences, dated the moment\nthe figures were worked out, so anything sold afterwards stacks on top of it.\nRefused, with nothing posted, while a register sale (POS Invoice not yet closed) is\nopen on any row being adjusted: ERPNext takes that stock out only when the register\ncloses, so a quantity set now would be wrong by exactly that much.\nFirearms are never adjusted here, no disposition is created and FastBound is not\ncalled: a missing gun needs a person to look into it. A count with no quantity\nentries at all (firearms only) finishes without a reconciliation.\n\n**Auth (derived from code):** Roles: Stock Manager / System Manager\n\nSource: `apps/ffl_core/ffl_core/api/inventory_count.py:1019`",
        "operationId": "ffl_core.api.inventory_count.finalize",
        "responses": {
          "200": {
            "description": "{ok, stock_reconciliation, adjusted: [{item_code, warehouse, expected, adjust_to}], skipped: [{item_code, item_name, warehouse, counted, reason}], serial: {missing, unexpected, unknown}}.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "count": {
                    "type": "string",
                    "description": "The Inventory Count name; must be open and have at least one scan."
                  },
                  "item_rows": {
                    "description": "The rows to adjust, as [{item_code, warehouse}] (list or JSON), so staff can untick rows on the page. Left out = every row with a difference EXCEPT items nobody scanned: those are only adjusted (to 0) when listed here. Quantities are always worked out again here, never taken from the caller."
                  }
                },
                "required": [
                  "count"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_core.api.inventory_count.get_counts": {
      "post": {
        "tags": [
          "ffl_core"
        ],
        "summary": "The most recent counts, newest first, with how many entries each holds.",
        "description": "**Auth (derived from code):** Roles: Stock User / Stock Manager / System Manager\n\nSource: `apps/ffl_core/ffl_core/api/inventory_count.py:184`",
        "operationId": "ffl_core.api.inventory_count.get_counts",
        "responses": {
          "200": {
            "description": "[{name, status, company, creation, owner, finalized_at, stock_reconciliation, entries, warehouses: [name], item_groups: [name]}].",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "array"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        }
      }
    },
    "/api/method/ffl_core.api.inventory_count.get_item_row": {
      "post": {
        "tags": [
          "ffl_core"
        ],
        "summary": "One row of the Items list, for an item another device (or a typed entry) just",
        "description": "added that this page has no row for yet — cheaper than reloading the whole state.\n\n**Auth (derived from code):** Roles: Stock User / Stock Manager / System Manager\n\nSource: `apps/ffl_core/ffl_core/api/inventory_count.py:950`",
        "operationId": "ffl_core.api.inventory_count.get_item_row",
        "responses": {
          "200": {
            "description": "{item_code, item_name, item_group, warehouse, expected, upc, counted, last_entry, last_delta}.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "count": {
                    "type": "string",
                    "description": "The Inventory Count name."
                  },
                  "item_code": {
                    "type": "string",
                    "description": "The item."
                  },
                  "warehouse": {
                    "type": "string",
                    "description": "The warehouse it was counted in."
                  }
                },
                "required": [
                  "count",
                  "item_code",
                  "warehouse"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_core.api.inventory_count.get_scope_options": {
      "post": {
        "tags": [
          "ffl_core"
        ],
        "summary": "What the New Count dialog can offer: the company and its countable warehouses.",
        "description": "**Auth (derived from code):** Roles: Stock User / Stock Manager / System Manager\n\nSource: `apps/ffl_core/ffl_core/api/inventory_count.py:115`",
        "operationId": "ffl_core.api.inventory_count.get_scope_options",
        "responses": {
          "200": {
            "description": "{company, warehouses: [name], default_warehouse}.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "company": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "description": "Company to list warehouses for; defaults to the user's company."
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_core.api.inventory_count.get_state": {
      "post": {
        "tags": [
          "ffl_core"
        ],
        "summary": "Everything the page shows for one count.",
        "description": "**Auth (derived from code):** Roles: Stock User / Stock Manager / System Manager\n\nSource: `apps/ffl_core/ffl_core/api/inventory_count.py:910`",
        "operationId": "ffl_core.api.inventory_count.get_state",
        "responses": {
          "200": {
            "description": "{status, server_time, found: {serial: {entry, by, at, method, item_code}}, counted: [{item_code, warehouse, counted, last_entry, last_delta}], unknown: [{entry, code, by, at}]} and, unless counts_only, also {company, warehouses, default_warehouse, stock_reconciliation, serials: [expected guns with label], items: [{item_code, item_name, warehouse, upc, expected, counted, last_entry, last_delta}]}.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "count": {
                    "type": "string",
                    "description": "The Inventory Count name."
                  },
                  "counts_only": {
                    "description": "1 for the light version the page polls every few seconds: only what has been scanned (found guns, counted quantities, unknown barcodes). A cursor (\"changes since\") cannot show an Undo, so this re-sends the whole folded tally, which is small.",
                    "default": 0
                  }
                },
                "required": [
                  "count"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_core.api.inventory_count.scan": {
      "post": {
        "tags": [
          "ffl_core"
        ],
        "summary": "Record one scan: a firearm's serial number or an item's barcode.",
        "description": "The code is tried as a serial number first (case and surrounding spaces ignored),\nthen as an item barcode (UPC). A serial adds the gun once; scanning it again changes nothing. A UPC adds 1 to\nthat item in ``warehouse``. A code that matches neither is saved as an unknown\nbarcode so it shows in the report.\n\n**Auth (derived from code):** Roles: Stock User / Stock Manager / System Manager\n\nSource: `apps/ffl_core/ffl_core/api/inventory_count.py:386`",
        "operationId": "ffl_core.api.inventory_count.scan",
        "responses": {
          "200": {
            "description": "{result: serial|already|item|unknown|error, message, serial, item_code, item_name, warehouse, expected, counted, entry (the row to undo), warning}. ``result`` error means nothing was saved (the message says why).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "count": {
                    "type": "string",
                    "description": "The Inventory Count name; must be open."
                  },
                  "code": {
                    "type": "string",
                    "description": "What the scanner typed."
                  },
                  "warehouse": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "description": "Where a UPC scan is being counted. Optional when the count covers one warehouse or the store's default warehouse is part of it."
                  }
                },
                "required": [
                  "count",
                  "code"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_core.api.inventory_count.set_qty": {
      "post": {
        "tags": [
          "ffl_core"
        ],
        "summary": "Type in the counted quantity for an item, for something with no barcode.",
        "description": "Saved as the difference from what is already counted, so scans from other\ndevices at the same moment are not overwritten.\n\n**Auth (derived from code):** Roles: Stock User / Stock Manager / System Manager\n\nSource: `apps/ffl_core/ffl_core/api/inventory_count.py:424`",
        "operationId": "ffl_core.api.inventory_count.set_qty",
        "responses": {
          "200": {
            "description": "{ok, counted, entry, last_entry, last_delta}; entry is null (and nothing changes) when the item was already counted at this quantity.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "count": {
                    "type": "string",
                    "description": "The Inventory Count name; must be open."
                  },
                  "item_code": {
                    "type": "string",
                    "description": "A non-serialized stock item."
                  },
                  "warehouse": {
                    "type": "string",
                    "description": "The warehouse it was counted in; must be part of the count."
                  },
                  "qty": {
                    "description": "The quantity found, 0 or more."
                  }
                },
                "required": [
                  "count",
                  "item_code",
                  "warehouse",
                  "qty"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_core.api.inventory_count.toggle_serial": {
      "post": {
        "tags": [
          "ffl_core"
        ],
        "summary": "Tick or untick a gun by hand, for a gun whose label will not scan.",
        "description": "**Auth (derived from code):** Roles: Stock User / Stock Manager / System Manager\n\nSource: `apps/ffl_core/ffl_core/api/inventory_count.py:476`",
        "operationId": "ffl_core.api.inventory_count.toggle_serial",
        "responses": {
          "200": {
            "description": "{ok, found, entry}.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "count": {
                    "type": "string",
                    "description": "The Inventory Count name; must be open."
                  },
                  "serial": {
                    "type": "string",
                    "description": "The serial number."
                  },
                  "found": {
                    "description": "1 to mark the gun as counted, 0 to remove its count. Taking away someone else's scan needs a Stock Manager."
                  }
                },
                "required": [
                  "count",
                  "serial",
                  "found"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_core.api.inventory_count.undo": {
      "post": {
        "tags": [
          "ffl_core"
        ],
        "summary": "Remove one scan or typed entry from an open count.",
        "description": "**Auth (derived from code):** Roles: Stock User / Stock Manager / System Manager\n\nSource: `apps/ffl_core/ffl_core/api/inventory_count.py:509`",
        "operationId": "ffl_core.api.inventory_count.undo",
        "responses": {
          "200": {
            "description": "{ok, kind, serial_no, code, item_code, warehouse, counted, last_entry, last_delta}: what the removal leaves behind (for a quantity entry, the item's new counted total and its newest remaining entry). Only the person who made the entry, or a Stock Manager, may remove it.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "entry": {
                    "type": "string",
                    "description": "The Inventory Count Entry name. Already gone counts as done."
                  }
                },
                "required": [
                  "entry"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_core.api.inventory_count.variance": {
      "post": {
        "tags": [
          "ffl_core"
        ],
        "summary": "The difference between what was counted and what the system says.",
        "description": "Non-serialized rows are what ``finalize`` would adjust. Firearms are only ever\nlisted. A finalized count returns the report saved when it was finalized.\n\n**Auth (derived from code):** Roles: Stock User / Stock Manager / System Manager\n\nSource: `apps/ffl_core/ffl_core/api/inventory_count.py:977`",
        "operationId": "ffl_core.api.inventory_count.variance",
        "responses": {
          "200": {
            "description": "{status, stock_reconciliation, serial: {missing, unexpected, unknown}, items: [{item_code, item_name, warehouse, expected, counted, moved, adjust_to, difference, never_scanned, open_register_sales: [{invoice, posted}]}], skipped: [{item_code, item_name, warehouse, counted, reason}], quantity_counted, entries}. ``moved`` is what sold or arrived since the item was counted. ``skipped`` items cannot be reconciled (adjust them by hand). ``open_register_sales`` lists POS sales not yet closed: a row with any cannot be adjusted (finalize refuses) until the register closes. ``quantity_counted`` is false for a firearms-only count, which finishes with the firearm report alone.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "count": {
                    "type": "string",
                    "description": "The Inventory Count name."
                  }
                },
                "required": [
                  "count"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_core.api.item_admin.add_stock": {
      "post": {
        "tags": [
          "ffl_core"
        ],
        "summary": "Quick stock receipt — creates and submits a Material Receipt Stock Entry.",
        "description": "Used by the \"+ Add Stock\" button on the Item form for everyday adjustments\n(found inventory, opening stock, manual top-up). Firearms tracked by\nSerial No are rejected — those go through Receive Goods so the FFL\ncompliance flow runs.\n\n**Auth (derived from code):** Roles: Stock Manager / System Manager\n\n**Permissions:** Stock Manager / System Manager.\n\nSource: `apps/ffl_core/ffl_core/api/item_admin.py:116`",
        "operationId": "ffl_core.api.item_admin.add_stock",
        "responses": {
          "200": {
            "description": "{ok, name, qty, warehouse}.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "item_code": {
                    "type": "string",
                    "description": "Non-serialized stock Item to receive."
                  },
                  "qty": {
                    "description": "Units to add, > 0."
                  },
                  "warehouse": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "description": "Optional target; defaults to the configured warehouse."
                  },
                  "rate": {
                    "description": "Optional per-unit cost; non-numeric or <= 0 is ignored and the cost on file is used instead (never the selling price)."
                  },
                  "remarks": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "description": "Optional Stock Entry remarks."
                  }
                },
                "required": [
                  "item_code",
                  "qty"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_core.api.item_admin.force_delete": {
      "post": {
        "tags": [
          "ffl_core"
        ],
        "summary": "DESTRUCTIVE: cancel referencing docs, drop links, delete Items outright.",
        "description": "Cancels referencing submitted docs, deletes referencing drafts, wipes\nsimple linked rows (Stock Ledger, Serial No, Bin, Batch, Item Price,\nFFL Acquisition/Disposition), then deletes the Items. Cancelled-doc\nhistory rows are left alone — they're audit trail.\n\n**Auth (derived from code):** Roles: System Manager\n\n**Permissions:** System Manager only (destructive).\n\nSource: `apps/ffl_core/ffl_core/api/item_admin.py:597`",
        "operationId": "ffl_core.api.item_admin.force_delete",
        "responses": {
          "200": {
            "description": "{ok, deleted: [...], cancelled: [{doctype, name}], deleted_drafts: [{doctype, name}], simple: [{doctype, count}], errors: [...], missing: [...]} — ok is False when any per-row step errored.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "item_codes": {
                    "description": "A list, JSON-encoded list, or comma-separated string."
                  },
                  "cancel_submitted": {
                    "description": "Must be truthy to proceed when submitted docs reference the Items; the UI re-prompts with True.",
                    "default": false
                  }
                },
                "required": [
                  "item_codes"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_core.api.item_admin.get_item_stock": {
      "post": {
        "tags": [
          "ffl_core"
        ],
        "summary": "Return {item_code: total_actual_qty} summed across all warehouses.",
        "description": "Reads from `tabBin` (the per-warehouse stock-on-hand cache). Items with\nno Bin row return 0. Designed for the Item list view + Item form to\nshow a stock badge without forcing the user to open Stock Balance.\n\n**Auth (derived from code):** Requires read permission on Item (Frappe DocType permission check).\n\nSource: `apps/ffl_core/ffl_core/api/item_admin.py:433`",
        "operationId": "ffl_core.api.item_admin.get_item_stock",
        "responses": {
          "200": {
            "description": "{item_code: total_actual_qty} — every requested code is present.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "item_codes": {
                    "description": "A list, JSON-encoded list, or comma-separated string."
                  }
                },
                "required": [
                  "item_codes"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_core.api.item_admin.preview_delete": {
      "post": {
        "tags": [
          "ffl_core"
        ],
        "summary": "Preview a force_delete: per-doctype counts of rows that would be touched.",
        "description": "**Auth (derived from code):** Roles: System Manager\n\n**Permissions:** System Manager.\n\nSource: `apps/ffl_core/ffl_core/api/item_admin.py:521`",
        "operationId": "ffl_core.api.item_admin.preview_delete",
        "responses": {
          "200": {
            "description": "{item_codes, submitted: [{doctype, count}] (must be cancelled first), drafts: [{doctype, count}] (deleted without cancel), simple: [{doctype, count}] (direct delete), missing: [...]}.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "item_codes": {
                    "description": "A list, JSON-encoded list, or comma-separated string."
                  }
                },
                "required": [
                  "item_codes"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_core.api.item_admin.recompute_all_item_actual_qty": {
      "post": {
        "tags": [
          "ffl_core"
        ],
        "summary": "One-shot reconciliation: refresh Item.actual_qty for every Item from",
        "description": "current Bin sums in a single bulk UPDATE. Useful after migrate to backfill\nthe new field, or after data imports / direct-DB tweaks.\n\nTwo statements:\n1. UPDATE Item JOIN (SUM Bin) — set qty for items that have Bin rows\n2. UPDATE Item — zero out items with no Bin rows (e.g. after Force Delete)\n\n**Auth (derived from code):** Roles: System Manager\n\n**Permissions:** System Manager.\n\nSource: `apps/ffl_core/ffl_core/api/item_admin.py:392`",
        "operationId": "ffl_core.api.item_admin.recompute_all_item_actual_qty",
        "responses": {
          "200": {
            "description": "{\"with_bin\": <count of items that have Bin rows>}.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        }
      }
    },
    "/api/method/ffl_core.api.item_admin.set_stock": {
      "post": {
        "tags": [
          "ffl_core"
        ],
        "summary": "Adjust stock to an absolute quantity via Stock Reconciliation.",
        "description": "Used by the \"Adjust Quantity\" button on the Item form when the user\nwants to set on-hand to a specific number (post-physical-count, found\ninventory correction, write-off). For positive deltas a Material\nReceipt is faster (see add_stock); set_stock is the right primitive\nwhen the user already knows the absolute target.\n\nThe quantity entered is what is on the shelf now. A register sale not yet\nclosed has left the shelf but is still in the Bin (ERPNext posts it at the\nregister close), so the reconciliation sets the Bin to the entered quantity\nplus those units; once the close posts them the Bin reads the entered figure.\n\n**Auth (derived from code):** Roles: Stock Manager / System Manager\n\n**Permissions:** Stock Manager / System Manager.\n\nSource: `apps/ffl_core/ffl_core/api/item_admin.py:203`",
        "operationId": "ffl_core.api.item_admin.set_stock",
        "responses": {
          "200": {
            "description": "{ok, name (Stock Reconciliation #), prev_qty, new_qty (as entered), open_register_qty (units on register sales not closed yet), delta (what the reconciliation changed the Bin by), warehouse}.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "item_code": {
                    "type": "string",
                    "description": "Non-serialized stock Item to adjust."
                  },
                  "new_qty": {
                    "description": "Units physically on the shelf now, >= 0."
                  },
                  "warehouse": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "description": "Optional target; defaults to the configured warehouse."
                  },
                  "reason": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "description": "Optional audit note (stored as a Comment on the Stock Reconciliation)."
                  }
                },
                "required": [
                  "item_code",
                  "new_qty"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_core.api.manual_order.available_serials": {
      "post": {
        "tags": [
          "ffl_core"
        ],
        "summary": "In-stock serials (+ sell/cost price) for the Create Order serial picker.",
        "description": "Thin pass-through to the canonical firearm helper.\n\nexclude_unavailable=False: this Create Order picker keeps its existing\nbehaviour (the held/consigned exclusion applies to the THREE POS\nfirearm.py pickers, not this alias). The counter's real gate is\n_serial_status at scan-to-add / submit, which already rejects a held gun and\nhonours ignore_invoice for the order being edited.\n\n**Auth (derived from code):** Roles: Sales User / Sales Manager / Stock Manager / System Manager\n\n**Permissions:** Sales User / Sales Manager / Stock Manager / System Manager.\n\nSource: `apps/ffl_core/ffl_core/api/manual_order.py:3915`",
        "operationId": "ffl_core.api.manual_order.available_serials",
        "responses": {
          "200": {
            "description": "{item_code: [{serial, sell_price, cost, ...}]} (see firearm.available_serials_with_prices).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "item_codes": {
                    "description": "Item code(s) — list, JSON list, or comma-separated."
                  }
                },
                "required": [
                  "item_codes"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_core.api.manual_order.cancel_order": {
      "post": {
        "tags": [
          "ffl_core"
        ],
        "summary": "Cancel a counter order: cascade documents, refund what was paid.",
        "description": "The Pending Order page's Cancel Order action. The POS document work\ncommits first — cancel the invoice (its own on_cancel hook cascades the\nFFL/Dealer Transfer dispositions → Material Issue reversal → queued\nFastBound delete), cancel the linked Sales Order(s), and book a refund\nPayment Entry for whatever was actually paid (an at-counter inline payment\nis first restored to its own accounts, since the invoice cancel reversed\nit) — then a best-effort\nShipStation void runs after that commit. Never deletes documents —\ncancelled records stay as the audit trail. Orders carrying a 4473\ndisposition are refused.\n\n**Auth (derived from code):** Roles: Sales User / Sales Manager / Stock Manager / System Manager\n\n**Permissions:** Sales User / Sales Manager / Stock Manager / System Manager.\n\nSource: `apps/ffl_core/ffl_core/api/manual_order.py:3139`",
        "operationId": "ffl_core.api.manual_order.cancel_order",
        "responses": {
          "200": {
            "description": "{ok, dispositions_cancelled, delivery_notes_cancelled, sales_orders_cancelled, refund_entry, refunded_amount, shipstation_voided, warning, ...}.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "sales_invoice": {
                    "type": "string",
                    "description": "Submitted counter-order Sales Invoice name."
                  },
                  "reason": {
                    "type": "string",
                    "description": "Required free-text cancellation reason."
                  },
                  "refund_mode": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "description": "Payment mode for the refund entry (required when anything was paid)."
                  },
                  "refund_reference": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "description": "Processor reference (required for Zelle, ACH and Check/Money Order refunds)."
                  }
                },
                "required": [
                  "sales_invoice",
                  "reason"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_core.api.manual_order.check_serials_available": {
      "post": {
        "tags": [
          "ffl_core"
        ],
        "summary": "Bulk, non-throwing serial validation for draft resume / edit prefill.",
        "description": "Resuming a draft re-checks every parked firearm (drafts don't reserve\nstock, so a gun may have sold in the meantime).\n\n**Auth (derived from code):** Roles: Sales User / Sales Manager / Stock Manager / System Manager\n\n**Permissions:** Sales User / Sales Manager / Stock Manager / System Manager.\n\nSource: `apps/ffl_core/ffl_core/api/manual_order.py:3778`",
        "operationId": "ffl_core.api.manual_order.check_serials_available",
        "responses": {
          "200": {
            "description": "{typed_term: {ok: True, ...line data} | {ok: False, reason}}.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "serials": {
                    "description": "List (or JSON-encoded list) of typed serial terms."
                  },
                  "ignore_invoice": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "description": "Exempts the edited order's own hold — the Edit prefill re-checks the order's own serials, which must not read as unavailable."
                  },
                  "customer": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "description": "The order's buyer: a gun held for their CRM deal is theirs to buy."
                  }
                },
                "required": [
                  "serials"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_core.api.manual_order.create_order": {
      "post": {
        "tags": [
          "ffl_core"
        ],
        "summary": "Build a counter order: submitted Sales Order → Sales Invoice.",
        "description": "The Create Order page's single entry point. Handles firearm orders\n(destination FFL required, optional immediate Dispose & Ship),\naccessory/direct orders, distributor drop-ship legs, tax exemption,\nand full or partial payment. Everything runs in one transaction — a\nfailure anywhere rolls the whole order back.\n\n**Auth (derived from code):** Roles: Sales User / Sales Manager / Stock Manager / System Manager\n\n**Permissions:** Sales User / Sales Manager / Stock Manager / System Manager.\n\nSource: `apps/ffl_core/ffl_core/api/manual_order.py:253`",
        "operationId": "ffl_core.api.manual_order.create_order",
        "responses": {
          "200": {
            "description": "{ok, sales_order, sales_invoice, paid_amount, outstanding, disposed, ship_pushed, ship_error, email_to, agreements: [{template, serial_no, state: sent / link_open / failed, email, token_expires, error}], agreement_email_error, ship_held_for_agreements}.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "payload": {
                    "description": "{ buyer_type: \"individual\" | \"business\", customer, destination_ffl?, mode_of_payment, payment_received: bool, paid_amount?, shipping_amount?, dispose_now: bool, items: [{item_code, qty, rate, serials: [...], storage_location?}] — storage_location: the in-store location a loose-stock line is taken from (an open location; the units leave it when the stock does, and nothing blocks if it holds less), recipient_name?, recipient_phone?, contact_email?, pickup_in_store?: bool — the customer collects here: no ship-to is stored; drop-ship lines and a destination FFL are refused, and a regulated firearm is allowed only as a ship-to-store line (it is handed over on a POS Invoice, with its 4473, once it arrives), ship_to?: {address_line1, address_line2, city, state, pincode}, notes?, pos_profile?, tax_exempt?, tax_certificate?, draft?, le_excise_exempt?, le_exempt_buyer?, le_exempt_certificate? — a peace officer's (or their agency's) sale: the excise tax comes off, sales tax stays; buyer and CDTFA-230-FET certificate required (compliance.le_excise_exempt), price_approval? — a manager's approval token for prices below list (price_approval.approve; needed while FFL Settings asks for one), crm_deal? — the CRM Deal this order came from: kept on the invoice, which writes back to it (crm.orders); one that no longer exists is dropped and the order goes on } — dict or JSON string. Agreements the buyer has not signed yet (FFL Settings › Used Item Agreement, an Item's required agreement) do not stop the order: each is emailed to the order's email (else the customer's) and Dispose waits for it; a dispose_now order is then held back on Pending Order (``ship_held_for_agreements``). A failed or impossible email never undoes the order — it is reported."
                  }
                },
                "required": [
                  "payload"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_core.api.manual_order.delete_order_draft": {
      "post": {
        "tags": [
          "ffl_core"
        ],
        "summary": "Delete a Create Order Draft (missing names are ignored).",
        "description": "Also the consumed-draft cleanup create_order calls after success.\n\n**Auth (derived from code):** Roles: Sales User / Sales Manager / Stock Manager / System Manager\n\n**Permissions:** Sales User / Sales Manager / Stock Manager / System Manager.\n\nSource: `apps/ffl_core/ffl_core/api/manual_order.py:3894`",
        "operationId": "ffl_core.api.manual_order.delete_order_draft",
        "responses": {
          "200": {
            "description": "{\"ok\": True}.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "name": {
                    "type": "string",
                    "description": "Create Order Draft name."
                  }
                },
                "required": [
                  "name"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_core.api.manual_order.dispose_order": {
      "post": {
        "tags": [
          "ffl_core"
        ],
        "summary": "Dispose (ship) the firearms on a submitted order — the queue action.",
        "description": "Books one transfer disposition per not-yet-disposed serial; the\ndisposition's own on_submit issues the stock-out Material Issue and\nenqueues the FastBound push. Idempotent. Gated on the pre-ship payment\nrule (ship_payment_block), a valid destination FFL and the agreements the\nsale needs: an unsigned one refuses (``AgreementRequired``) unless\n``override_agreement`` is 1, which disposes anyway and records who, what\nwas unsigned and why as a comment on the invoice. The signed Each firearm\nsold copies then belong to this invoice.\n\n**Auth (derived from code):** Roles: Sales User / Sales Manager / Stock Manager / System Manager\n\n**Permissions:** Sales User / Sales Manager / Stock Manager / System Manager.\n\nSource: `apps/ffl_core/ffl_core/api/manual_order.py:1646`",
        "operationId": "ffl_core.api.manual_order.dispose_order",
        "responses": {
          "200": {
            "description": "{\"ok\": True, \"dispositions\": [names], \"disposed_count\": n, \"agreement_override\": whether unsigned agreements were overridden}.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "sales_invoice": {
                    "type": "string",
                    "description": "Submitted Sales Invoice with a destination FFL."
                  },
                  "override_agreement": {
                    "type": "integer",
                    "description": "1 to dispose although agreements are unsigned.",
                    "default": 0
                  },
                  "reason": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "description": "Why, for the override's comment (optional)."
                  }
                },
                "required": [
                  "sales_invoice"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_core.api.manual_order.find_serial_for_order": {
      "post": {
        "tags": [
          "ffl_core"
        ],
        "summary": "Scan-to-add for the Create Order page: resolve a firearm serial number",
        "description": "straight to an order line (canonical serial + item + tag price). Throws\nwith the specific reason when the gun can't be sold — unknown serial, not\nin stock, held by a web order, or already on an open counter order. The\nprice comes from the same available_serials_with_prices pass the serial\ndropdown uses, so both entry paths always quote identically.\n\n**Auth (derived from code):** Roles: Sales User / Sales Manager / Stock Manager / System Manager\n\n**Permissions:** Sales User / Sales Manager / Stock Manager / System Manager.\n\nSource: `apps/ffl_core/ffl_core/api/manual_order.py:3746`",
        "operationId": "ffl_core.api.manual_order.find_serial_for_order",
        "responses": {
          "200": {
            "description": "Order-line data: canonical serial, item_code/item_name, and the tag price.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "serial": {
                    "type": "string",
                    "description": "Scanned/typed serial number."
                  },
                  "ignore_invoice": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "description": "Exempts the edited order's own hold, so staff can delete then re-scan the same gun mid-edit."
                  },
                  "customer": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "description": "The order's buyer: a gun held for their CRM deal is theirs to buy. Held for anyone else, the refusal is a DealHoldError."
                  }
                },
                "required": [
                  "serial"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_core.api.manual_order.fulfill_from_stock": {
      "post": {
        "tags": [
          "ffl_core"
        ],
        "summary": "Serve a ship-to-store line from shelf stock instead of waiting for the",
        "description": "distributor's parcel.\n\nThe line becomes an ordinary local leg: its ship-to-store pin is cleared, a\ngun gets the chosen in-stock serial written on (the counter hold), an\naccessory keeps its quantity for the Delivery Note leg. The Distributor Order\nis NOT cancelled (no cancel API at either house): its line's\n``substituted_qty`` goes up, so the queue stops waiting for it and, when the\nparcel lands, the Receive Goods scan books it as plain restock instead of\nholding it for this order. Refused once the goods have arrived (the line\nalready carries its serial), for a serial that is not an unheld, in-stock\nunit of the item, or for an accessory the shelf cannot cover.\n\n**Auth (derived from code):** Roles: Sales User / Sales Manager / Stock Manager / System Manager\n\n**Permissions:** Sales User / Sales Manager / Stock Manager / System Manager.\n\nSource: `apps/ffl_core/ffl_core/api/manual_order.py:2445`",
        "operationId": "ffl_core.api.manual_order.fulfill_from_stock",
        "responses": {
          "200": {
            "description": "{order, row_name, serial_no, do_name, substituted_qty}.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "sales_invoice": {
                    "type": "string",
                    "description": "The counter order."
                  },
                  "row_name": {
                    "type": "string",
                    "description": "The Sales Invoice Item row."
                  },
                  "serial_no": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "description": "For a firearm line, the in-stock serial to hold."
                  }
                },
                "required": [
                  "sales_invoice",
                  "row_name"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_core.api.manual_order.get_customer_tax_status": {
      "post": {
        "tags": [
          "ffl_core"
        ],
        "summary": "Tax-exempt flag + certificate URL for a customer.",
        "description": "Lets the Create Order page pre-fill a Business buyer's existing\nexemption.\n\n**Auth (derived from code):** Roles: Sales User / Sales Manager / Stock Manager / System Manager\n\n**Permissions:** Sales User / Sales Manager / Stock Manager / System Manager.\n\nSource: `apps/ffl_core/ffl_core/api/manual_order.py:5117`",
        "operationId": "ffl_core.api.manual_order.get_customer_tax_status",
        "responses": {
          "200": {
            "description": "{\"is_tax_exempt\": 0|1, \"certificate\": <file URL or null>}.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "customer": {
                    "type": "string",
                    "description": "Customer name."
                  }
                },
                "required": [
                  "customer"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_core.api.manual_order.get_order_draft": {
      "post": {
        "tags": [
          "ffl_core"
        ],
        "summary": "Load one Create Order Draft for resume.",
        "description": "**Auth (derived from code):** Roles: Sales User / Sales Manager / Stock Manager / System Manager\n\n**Permissions:** Sales User / Sales Manager / Stock Manager / System Manager.\n\nSource: `apps/ffl_core/ffl_core/api/manual_order.py:3875`",
        "operationId": "ffl_core.api.manual_order.get_order_draft",
        "responses": {
          "200": {
            "description": "{\"name\": ..., \"title\": ..., \"payload\": <parsed payload dict>}.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "name": {
                    "type": "string",
                    "description": "Create Order Draft name."
                  }
                },
                "required": [
                  "name"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_core.api.manual_order.get_order_for_edit": {
      "post": {
        "tags": [
          "ffl_core"
        ],
        "summary": "Reconstruct the create_order payload from an editable pending order.",
        "description": "The Edit flow's prefill. Same shape _collectPayload/save_order_draft use,\nso the page hydrates it through the existing draft path. tax_exempt is\ndeliberately OMITTED: create_order then falls back to the customer's\nstanding flag, so an edit can never silently re-toggle the exemption.\n\n**Auth (derived from code):** Roles: Sales User / Sales Manager / Stock Manager / System Manager\n\n**Permissions:** Sales User / Sales Manager / Stock Manager / System Manager.\n\nSource: `apps/ffl_core/ffl_core/api/manual_order.py:2672`",
        "operationId": "ffl_core.api.manual_order.get_order_for_edit",
        "responses": {
          "200": {
            "description": "{payload: <create_order-shaped dict>, edit_ctx: {sales_invoice, customer, customer_name, contact_email, grand_total, paid_total, last_payment_mode, carry_block, shipping_tax_inclusive}}. A payload item whose goods are already on order carries ``ordered_do`` (that order's name): the page locks the row, and update_order enforces the lock against the orders themselves.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "sales_invoice": {
                    "type": "string",
                    "description": "Submitted counter-order Sales Invoice (must pass the editable gate: undisposed, never pushed, no completed pickup)."
                  }
                },
                "required": [
                  "sales_invoice"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_core.api.manual_order.item_tax_rates": {
      "post": {
        "tags": [
          "ffl_core"
        ],
        "summary": "Per-item sales-tax rate for the Create Order preview.",
        "description": "The summed \"On Net Total\" rate of the company's default sales-tax template\nas it applies to each item once ERPNext's Item Tax Template resolution\n(the item's own templates, then its item groups') has overridden the\ntemplate rows — the same rate compliance.shipping_charge._effective_rate\nreads off the saved line. A 0% (or Not Applicable) template gives 0, so\nthe preview shows no goods tax on a service-only order and, like the\nserver, no tax on or inside its shipping.\n\n**Auth (derived from code):** Roles: Sales User / Sales Manager / Stock Manager / System Manager\n\n**Permissions:** Sales User / Sales Manager / Stock Manager / System Manager.\n\nSource: `apps/ffl_core/ffl_core/api/manual_order.py:5066`",
        "operationId": "ffl_core.api.manual_order.item_tax_rates",
        "responses": {
          "200": {
            "description": "{<item_code>: <rate %>} for every known item.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "item_codes": {
                    "description": "List (or JSON list) of Item codes."
                  },
                  "company": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "description": "Optional company; defaults to the configured default."
                  },
                  "excise_exempt": {
                    "type": "integer",
                    "description": "1 for a peace officer's sale — the excise account's rows (compliance.le_excise_exempt) are left out of the rate.",
                    "default": 0
                  }
                },
                "required": [
                  "item_codes"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_core.api.manual_order.list_order_drafts": {
      "post": {
        "tags": [
          "ffl_core"
        ],
        "summary": "Shared draft list, newest first — shown in the page's Drafts dialog.",
        "description": "**Auth (derived from code):** Roles: Sales User / Sales Manager / Stock Manager / System Manager\n\n**Permissions:** Sales User / Sales Manager / Stock Manager / System Manager.\n\nSource: `apps/ffl_core/ffl_core/api/manual_order.py:3858`",
        "operationId": "ffl_core.api.manual_order.list_order_drafts",
        "responses": {
          "200": {
            "description": "List of {name, title, customer, total, modified, modified_by}.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "array"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        }
      }
    },
    "/api/method/ffl_core.api.manual_order.list_pending_dispositions": {
      "post": {
        "tags": [
          "ffl_core"
        ],
        "summary": "The Pending Order queue — every submitted counter order that still needs",
        "description": "work: undisposed firearm serials (needs disposing), an outstanding balance\n(needs payment), or deferred physical stock that hasn't shipped (needs its\nShipStation push / Delivery Note leg). FFL shipments and direct orders (no\ndestination FFL — accessories shipping to the buyer, or a counter pickup)\nboth live here; a fully-handled order leaves the queue. A business order\nshipped on account therefore stays until paid, and a dispose-now order\nappears (already disposed) until its shipment is pushed.\n\n**Auth (derived from code):** Roles: Sales User / Sales Manager / Stock Manager / System Manager\n\n**Permissions:** Sales User / Sales Manager / Stock Manager / System Manager.\n\nSource: `apps/ffl_core/ffl_core/api/manual_order.py:963`",
        "operationId": "ffl_core.api.manual_order.list_pending_dispositions",
        "responses": {
          "200": {
            "description": "One card per order: invoice identity/customer/totals, paid state, pending vs disposed serials per item, fulfillment leg state (local/dropship, releasable), ship_to_preview, has_ship_address, shipstation state, and ship_items (when ShipStation is enabled).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "array"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "customer": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "description": "Only this customer's orders. Default: everyone's."
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_core.api.manual_order.mark_shipped_manually": {
      "post": {
        "tags": [
          "ffl_core"
        ],
        "summary": "Clear an order from the Pending Order queue without a ShipStation push",
        "description": "— the escape hatch for a destination FFL that expired AFTER dispose, a\nmisconfigured integration, a label bought outside ShipStation, or a\ndirect order handed over at the counter. Books the Delivery Note leg for\ndeferred non-firearm stock lines (stock + COGS), then stamps\nshipstation_status='Shipped' with no order id (the same convention as the\nlegacy migration stamp), which satisfies the queue's retention rule.\n\nUndisposed firearms no longer refuse — the same as the ShipStation push,\nwhich has always been independent of Dispose. This clears the SHIPPING\nhalf only: no disposition, no FastBound push, and the gun's stock still\nleaves through its disposition's Material Issue, so the row stays on the\nqueue with its Dispose button and the caller is warned\n(warn_undisposed_firearms). The pre-ship payment rule (ship_payment_block\n— the same gate dispose_order and push_shipment share) still applies:\nthis path really moves the non-firearm goods.\n\n**Auth (derived from code):** Roles: Sales User / Sales Manager / Stock Manager / System Manager\n\n**Permissions:** Sales User / Sales Manager / Stock Manager / System Manager.\n\nSource: `apps/ffl_core/ffl_core/api/manual_order.py:1979`",
        "operationId": "ffl_core.api.manual_order.mark_shipped_manually",
        "responses": {
          "200": {
            "description": "{\"ok\": True, \"delivery_notes\": [...], \"undisposed_serials\": [...]} — undisposed_serials names the firearms whose bound-book entry is still owed. Or {\"ok\": True, \"already\": True, \"shipstation_status\": ...} when already pushed/marked.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "sales_invoice": {
                    "type": "string",
                    "description": "Submitted counter-order Sales Invoice name."
                  }
                },
                "required": [
                  "sales_invoice"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_core.api.manual_order.order_agreements": {
      "post": {
        "tags": [
          "ffl_core"
        ],
        "summary": "The agreements a counter order's sale needs and whether the buyer signed —",
        "description": "the Pending Order card's Agreements strip.\n\n**Auth (derived from code):** Roles: Sales User / Sales Manager / Stock Manager / System Manager\n\nSource: `apps/ffl_core/ffl_core/api/manual_order.py:1733`",
        "operationId": "ffl_core.api.manual_order.order_agreements",
        "responses": {
          "200": {
            "description": "{\"email\": where a link goes, \"rows\": [{template, serial_no, item_code, state (signed / expiring / expired / pending / missing), signed, token_expires, link_open, sent_by}]}.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "sales_invoice": {
                    "type": "string",
                    "description": "Submitted counter-order Sales Invoice."
                  }
                },
                "required": [
                  "sales_invoice"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_core.api.manual_order.order_line_costs": {
      "post": {
        "tags": [
          "ffl_core"
        ],
        "summary": "Unit cost of each Create Order line, for the page's read-only Cost column.",
        "description": "Display only — nothing here feeds create_order or its checks. Each line is\ncosted through the figure the store already keeps for it: a serial →\nSerial No.purchase_rate (the Sales Report's gun cost); a drop-ship / ship\nto store line → the Distributor Order line's unit_cost on the order being\nedited, else that house's catalog quote (the Fulfillment plan's cost); any\nother store line → its stock valuation, else last purchase rate (the\nfulfilment-options local cost). A line with no house chosen yet, or a gun\nwithout a serial, has no cost to show.\n\n**Auth (derived from code):** Roles: Sales User / Sales Manager / Stock Manager / System Manager\n\nSource: `apps/ffl_core/ffl_core/api/manual_order.py:3941`",
        "operationId": "ffl_core.api.manual_order.order_line_costs",
        "responses": {
          "200": {
            "description": "One unit cost per line, in input order — a float, or None when it is not known (never 0).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "array"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "items": {
                    "description": "Create Order lines — list or JSON list of {item_code, serials, channel or source, distributor or dropship_distributor, sku}."
                  },
                  "sales_invoice": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "description": "The order being edited, whose Distributor Orders carry its distributor lines' costs."
                  }
                },
                "required": [
                  "items"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_core.api.manual_order.pending_orders_digest": {
      "post": {
        "tags": [
          "ffl_core"
        ],
        "summary": "Morning summary of stuck counter orders for the managers — every blocked",
        "description": "row and every row older than FFL Settings → pending_order_age_alert_days.\n\nScheduled daily; sent once per day (a manual re-run the same day is a no-op\nbefore the queue is even read); sends nothing when nothing is stuck. Counter\nrows only (web and GunBroker rows are listed on the page but paid / handled\nelsewhere).\n\n**Auth (derived from code):** Roles: Stock Manager / System Manager\n\n**Permissions:** Inventory roles (the scheduler runs as Administrator, whom the gate exempts).\n\nSource: `apps/ffl_core/ffl_core/api/manual_order.py:908`",
        "operationId": "ffl_core.api.manual_order.pending_orders_digest",
        "responses": {
          "200": {
            "description": "{lines: <count>, sent: <bool>}.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        }
      }
    },
    "/api/method/ffl_core.api.manual_order.quick_create_individual": {
      "post": {
        "tags": [
          "ffl_core"
        ],
        "summary": "Create an individual (non-dealer) Customer with a primary Contact.",
        "description": "The Contact carries the receipt email.\n\n**Auth (derived from code):** Roles: Sales User / Sales Manager / Stock Manager / System Manager\n\n**Permissions:** Sales User / Sales Manager / Stock Manager / System Manager.\n\nSource: `apps/ffl_core/ffl_core/api/manual_order.py:4067`",
        "operationId": "ffl_core.api.manual_order.quick_create_individual",
        "responses": {
          "200": {
            "description": "{name, customer_name, email_id, phone}.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "payload": {
                    "description": "{customer_name (required), email_id (required — receipt destination), phone?} — dict or JSON string."
                  }
                },
                "required": [
                  "payload"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_core.api.manual_order.quote_config": {
      "post": {
        "tags": [
          "ffl_core"
        ],
        "summary": "Tax preview config for the Create Order page.",
        "description": "The home state and the default On-Net-Total sales-tax rate, so the page\ncan show the running tax without a round-trip per keystroke. The\nauthoritative tax is still computed server-side at create time from the\nshipping address.\n\n**Auth (derived from code):** Roles: Sales User / Sales Manager / Stock Manager / System Manager\n\n**Permissions:** Sales User / Sales Manager / Stock Manager / System Manager.\n\nSource: `apps/ffl_core/ffl_core/api/manual_order.py:5025`",
        "operationId": "ffl_core.api.manual_order.quote_config",
        "responses": {
          "200": {
            "description": "{\"home_state\": ..., \"rate\": <summed On Net Total %>, \"freight_taxable\": bool, \"shipping_tax_inclusive\": bool (a new order's shipping includes its sales tax — FFL Settings), \"us_states\": {<state name>: <USPS code>}, \"le_exempt_offered\": bool (a California store that names the excise account a peace officer is exempt from), \"le_excise_rate\": <that account's On Net Total % in the default template>}.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "company": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "description": "Optional company; defaults to the configured default."
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_core.api.manual_order.record_payment": {
      "post": {
        "tags": [
          "ffl_core"
        ],
        "summary": "Record a later payment against a submitted, not-fully-paid Sales Invoice —",
        "description": "the Pending Order \"Record Payment\" action for when a customer pays after the\norder was created on account. Builds and submits a Payment Entry for the full\noutstanding (or a smaller partial `amount`), booked to the Mode of Payment's\naccount, and returns the updated balance.\n\n**Auth (derived from code):** Roles: Sales User / Sales Manager / Stock Manager / System Manager\n\n**Permissions:** Sales User / Sales Manager / Stock Manager / System Manager.\n\nSource: `apps/ffl_core/ffl_core/api/manual_order.py:1455`",
        "operationId": "ffl_core.api.manual_order.record_payment",
        "responses": {
          "200": {
            "description": "{ok, payment_entry, paid_amount, outstanding, paid}.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "sales_invoice": {
                    "type": "string",
                    "description": "Submitted, not-fully-paid Sales Invoice name."
                  },
                  "mode_of_payment": {
                    "type": "string",
                    "description": "Cash, Credit Card, Zelle, ACH or Check/Money Order; Zelle, ACH and Check/Money Order also require transaction_number."
                  },
                  "amount": {
                    "description": "Optional partial amount (> 0, at most the outstanding balance); blank pays the full outstanding."
                  },
                  "transaction_number": {
                    "description": "Processor reference — the check or money order number for Check/Money Order. Required for Zelle, ACH and Check/Money Order, and for the card tender on a store running the standalone terminal with approval codes required — or with the card processor's terminal live (a card typed in here was run on the Virtual Terminal)."
                  },
                  "received_on": {
                    "description": "The day the money arrived (blank → today): it dates the Payment Entry, so a collection typed in late still books in the period the deposit really landed in. See _received_on_posting_date for the window."
                  }
                },
                "required": [
                  "sales_invoice",
                  "mode_of_payment"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_core.api.manual_order.release_order_legs": {
      "post": {
        "tags": [
          "ffl_core"
        ],
        "summary": "Release the Draft distributor legs of a counter or web order.",
        "description": "P1 — one-click release: confirms every Draft\nDistributor Order sourced from the order. The payment rule is the\nleg's (ffl_integrations.distributor.api.placement_payment_block, applied\nby confirm_order): a counter drop-ship leg needs the invoice settled, a\nship-to-store leg may go out on a deposit or unpaid, and a web order's\nlegs need the Woo order still paid — a leg the rule refuses lands in\n``failed`` with its reason and stays Draft. Each leg is\nsavepoint-isolated (a failing leg rolls back only its own half-writes,\nnever the siblings or the caller's transaction); confirm/place are\nidempotent, so a failed leg can be retried. Local/firearm legs keep\ntheir own queue buttons.\n\n**Auth (derived from code):** Roles: Sales User / Sales Manager / Stock Manager / System Manager\n\n**Permissions:** Sales User / Sales Manager / Stock Manager / System Manager.\n\nSource: `apps/ffl_core/ffl_core/api/manual_order.py:1543`",
        "operationId": "ffl_core.api.manual_order.release_order_legs",
        "responses": {
          "200": {
            "description": "{\"released\": [DO names], \"failed\": [{name, error}]}.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "sales_invoice": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "description": "Counter-order Sales Invoice name."
                  },
                  "woo_online_order": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "description": "Woo Online Order name, instead of sales_invoice."
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_core.api.manual_order.rename_customer": {
      "post": {
        "tags": [
          "ffl_core"
        ],
        "summary": "Fix a misspelled customer name SYSTEM-WIDE (the Edit form's pencil):",
        "description": "update customer_name, rename the doc when its id mirrors the name\n(ERPNext's default customer naming — rename_doc migrates every link), and\nrefresh the display-name snapshot on the customer's open sales documents.\nCancelled documents keep their historical spelling on purpose. The\nprimary Contact is NOT renamed (out of scope).\n\n**Auth (derived from code):** Roles: Sales User / Sales Manager / Stock Manager / System Manager\n\n**Permissions:** Sales User / Sales Manager / Stock Manager / System Manager.\n\nSource: `apps/ffl_core/ffl_core/api/manual_order.py:4120`",
        "operationId": "ffl_core.api.manual_order.rename_customer",
        "responses": {
          "200": {
            "description": "{\"name\": <possibly renamed id>, \"customer_name\": new_name}.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "customer": {
                    "type": "string",
                    "description": "Customer name (document id)."
                  },
                  "new_name": {
                    "type": "string",
                    "description": "Corrected display name."
                  }
                },
                "required": [
                  "customer",
                  "new_name"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_core.api.manual_order.resend_order_agreement": {
      "post": {
        "tags": [
          "ffl_core"
        ],
        "summary": "Email a counter order's buyer a fresh signing link (the old one stops working).",
        "description": "**Auth (derived from code):** Roles: Sales User / Sales Manager / Stock Manager / System Manager\n\nSource: `apps/ffl_core/ffl_core/api/manual_order.py:1751`",
        "operationId": "ffl_core.api.manual_order.resend_order_agreement",
        "responses": {
          "200": {
            "description": "{\"email\", \"token_expires\"}.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "sales_invoice": {
                    "type": "string",
                    "description": "Submitted counter-order Sales Invoice."
                  },
                  "template": {
                    "type": "string",
                    "description": "An agreement this order's sale needs."
                  },
                  "serial_no": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "description": "The gun, for an Each firearm sold agreement (the link covers every gun of the order still unsigned for it, unless it is signed once per gun)."
                  },
                  "email": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "description": "Send here instead of the order's email (else the customer's)."
                  }
                },
                "required": [
                  "sales_invoice",
                  "template"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_core.api.manual_order.resource_line": {
      "post": {
        "tags": [
          "ffl_core"
        ],
        "summary": "Order an unarrived ship-to-store line again from another house.",
        "description": "A Draft Distributor Order is created for the line at the new house (placed\nfrom the queue's Place order as usual); the old order's line is retired with\n``substituted_qty`` so the queue stops waiting on it and its parcel, if it\nstill comes, is restock. The old order is NOT cancelled at the distributor —\nneither house has a cancel API; the page tells the operator to phone them\nand quotes the web reference.\n\n**Auth (derived from code):** Roles: Sales User / Sales Manager / Stock Manager / System Manager\n\n**Permissions:** Sales User / Sales Manager / Stock Manager / System Manager.\n\nSource: `apps/ffl_core/ffl_core/api/manual_order.py:2300`",
        "operationId": "ffl_core.api.manual_order.resource_line",
        "responses": {
          "200": {
            "description": "{order, row_name, do_name: <new Draft DO>, retired: <old DO>}.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "sales_invoice": {
                    "type": "string",
                    "description": "The counter order."
                  },
                  "row_name": {
                    "type": "string",
                    "description": "The Sales Invoice Item row."
                  },
                  "distributor": {
                    "type": "string",
                    "description": "The house to order from now."
                  }
                },
                "required": [
                  "sales_invoice",
                  "row_name",
                  "distributor"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_core.api.manual_order.save_cr_ffl": {
      "post": {
        "tags": [
          "ffl_core"
        ],
        "summary": "Record a C&R (Type 03) collector's license and return its ATF FFL Record.",
        "description": "verify_ffl cannot serve a collector: the ATF's public FFL list contains no\nType 03 licensees at all (that is the whole reason this path exists), so\nthe destination's name, premises and expiry come from a human reading the\nlicense copy at the counter. This is that capture for the Create Order\npage — the same validation the web-order dispose runs\n(compliance.cr_transfer), so the counter cannot accept what the queue\nwould reject.\n\nThe record it upserts is an ordinary destination FFL from here on: the\nship-to, the destination-based sales tax and the FFL Transfer disposition\nall read it the way they read any other.\n\n**Auth (derived from code):** Roles: Sales User / Sales Manager / Stock Manager / System Manager\n\n**Permissions:** Sales User / Sales Manager / Stock Manager / System Manager.\n\nSource: `apps/ffl_core/ffl_core/api/manual_order.py:4016`",
        "operationId": "ffl_core.api.manual_order.save_cr_ffl",
        "responses": {
          "200": {
            "description": "{name}: the ATF FFL Record to post back as destination_ffl.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "cr_details": {
                    "description": "{license_number, license_expiry, contact_name, premise_street, premise_street2?, premise_city, premise_state, premise_zip} — dict or JSON string."
                  }
                },
                "required": [
                  "cr_details"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_core.api.manual_order.save_order_draft": {
      "post": {
        "tags": [
          "ffl_core"
        ],
        "summary": "Park the Create Order page's form state as a shared draft (upsert).",
        "description": "The create_order payload shape plus display extras, stored as a Create\nOrder Draft; upserts when `name` is passed. The list columns\n(customer/total/title) are derived here from the same items shape\ncreate_order itself consumes. Drafts reserve NOTHING; serials are\nre-validated on resume.\n\n**Auth (derived from code):** Roles: Sales User / Sales Manager / Stock Manager / System Manager\n\n**Permissions:** Sales User / Sales Manager / Stock Manager / System Manager.\n\nSource: `apps/ffl_core/ffl_core/api/manual_order.py:3815`",
        "operationId": "ffl_core.api.manual_order.save_order_draft",
        "responses": {
          "200": {
            "description": "{\"name\": ..., \"title\": ...}.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "payload": {
                    "description": "create_order-shaped payload (dict or JSON string)."
                  },
                  "name": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "description": "Existing draft name to update; blank creates a new one."
                  },
                  "title": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "description": "Optional display title; defaults to \"<buyer> · N item(s)\"."
                  }
                },
                "required": [
                  "payload"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_core.api.manual_order.set_customer_tax_exempt": {
      "post": {
        "tags": [
          "ffl_core"
        ],
        "summary": "Persist a customer's sales-tax-exempt status (+ optional certificate).",
        "description": "Checking the exemption is enough to exempt; the certificate is optional\nand, once on file, is attached to the Customer (retrievable any time)\nand reused.\n\n**Auth (derived from code):** Roles: Sales User / Sales Manager / Stock Manager / System Manager\n\n**Permissions:** Sales User / Sales Manager / Stock Manager / System Manager.\n\nSource: `apps/ffl_core/ffl_core/api/manual_order.py:5141`",
        "operationId": "ffl_core.api.manual_order.set_customer_tax_exempt",
        "responses": {
          "200": {
            "description": "{\"ok\": True, \"is_tax_exempt\": 0|1, \"certificate\": <URL or the one already on file>}.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "customer": {
                    "type": "string",
                    "description": "Customer name."
                  },
                  "exempt": {
                    "description": "Truthy (\"1\"/\"true\"/\"yes\") to exempt, else cleared."
                  },
                  "certificate": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "description": "Optional certificate file URL to keep on file."
                  }
                },
                "required": [
                  "customer",
                  "exempt"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_core.api.manual_order.update_order": {
      "post": {
        "tags": [
          "ffl_core"
        ],
        "summary": "Edit a pending counter order — the Pending Order page's Edit action.",
        "description": "Cancels the submitted invoice (+ its Sales Orders) and rebuilds it through\ncreate_order with the edited payload, in ONE transaction: editing is gated\nto undisposed, never-pushed orders, so there are no FastBound/ShipStation/\nstock side effects, and any failure rolls the whole edit back — the\noriginal order survives untouched. Deliberately NO frappe.db.commit()\nanywhere in this flow.\n\nMoney follows the order (_allocate_advances / _rebook_inline_tender);\noverpay refunds the difference (refund_mode required, Zelle also needs\nrefund_reference — same rules as cancel_order). A changed buyer refunds\nthe FULL paid amount to the ORIGINAL customer and the new invoice starts\nunpaid — unless carry_payment: then each receipt moves to the new buyer on\nits own day (the Receive PE is cancelled and amended, the card charge row\nfollows it; inline counter tender re-books dated the sale) and settles the\nrebuilt invoice; any excess refunds the way it was paid. A carry is all or\nnothing and refused before any change when a receipt cannot move\n(_carry_block).\n\nGoods a house is already sending follow the order too: those lines must come\nback unchanged (same house, lane and quantity — the price may change) and\ntheir Distributor Orders are re-pointed at the rebuilt invoice instead of\nbeing ordered again. New lines are planned and ordered as usual, so adding an\nitem to an order already placed buys just that item.\n\n**Auth (derived from code):** Roles: Sales User / Sales Manager / Stock Manager / System Manager\n\n**Permissions:** Sales User / Sales Manager / Stock Manager / System Manager.\n\nSource: `apps/ffl_core/ffl_core/api/manual_order.py:3308`",
        "operationId": "ffl_core.api.manual_order.update_order",
        "responses": {
          "200": {
            "description": "{ok, sales_invoice: <new SI>, replaced: <old SI>, sales_orders_cancelled, grand_total, carried_amount, refund_entry, refunded_amount, outstanding, agreements, agreement_email_error} — the last two as create_order's (a link still open is not sent again).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "sales_invoice": {
                    "type": "string",
                    "description": "Submitted counter-order Sales Invoice (editable gate applies)."
                  },
                  "payload": {
                    "description": "Edited create_order-shaped payload (dict or JSON string)."
                  },
                  "refund_mode": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "description": "Refund payment mode when the edit produces an overpay."
                  },
                  "refund_reference": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "description": "Processor reference (required for Zelle, ACH and Check/Money Order refunds)."
                  },
                  "carry_payment": {
                    "description": "1 when the buyer changed and what was paid should settle the rebuilt order under the new buyer instead of being refunded to the old one. Ignored when the buyer is unchanged.",
                    "default": 0
                  }
                },
                "required": [
                  "sales_invoice",
                  "payload"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_core.api.manual_order.verify_ffl": {
      "post": {
        "tags": [
          "ffl_core"
        ],
        "summary": "Live-verify an FFL number and upsert the ATF FFL Record.",
        "description": "Delegates to the eZ Check integration (online verify + address).\n\n**Auth (derived from code):** Roles: Sales User / Sales Manager / Stock Manager / System Manager\n\n**Permissions:** Sales User / Sales Manager / Stock Manager / System Manager.\n\nSource: `apps/ffl_core/ffl_core/api/manual_order.py:3995`",
        "operationId": "ffl_core.api.manual_order.verify_ffl",
        "responses": {
          "200": {
            "description": "The eZ Check lookup result (see ffl_integrations.atf.ez_check.lookup_and_create).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "ffl_number": {
                    "type": "string",
                    "description": "Full FFL number to verify."
                  }
                },
                "required": [
                  "ffl_number"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_core.api.marketing.close_request": {
      "post": {
        "tags": [
          "ffl_core"
        ],
        "summary": "Stop waiting on a reminder request: an Open request becomes Closed and is never notified.",
        "description": "Refused while marketing is switched off.\n\n**Auth (derived from code):** Roles: Marketing User / Sales Manager / System Manager\n\nSource: `apps/ffl_core/ffl_core/api/marketing.py:289`",
        "operationId": "ffl_core.api.marketing.close_request",
        "responses": {
          "200": {
            "description": "{\"request\": its name, \"status\": the status now, \"changed\": False when it was already Notified or Closed}.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "request": {
                    "type": "string",
                    "description": "The Marketing Request."
                  }
                },
                "required": [
                  "request"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_core.api.marketing.contact_card": {
      "get": {
        "tags": [
          "ffl_core"
        ],
        "summary": "One marketing contact: its record, tags, latest events and the reminders still waiting.",
        "description": "Refused while marketing is switched off.\n\n**Auth (derived from code):** Requires read permission on Marketing Contact (Frappe DocType permission check).\n\nSource: `apps/ffl_core/ffl_core/api/marketing.py:172`",
        "operationId": "ffl_core.api.marketing.contact_card",
        "responses": {
          "200": {
            "description": "{\"contact\": {email, first_name, last_name, status, source, consent_at, consent_channel, status_changed_at, status_reason, customer, creation, tags, suppressed}, \"events\": [{kind, occurred_at, mail, campaign, detail}] newest first, \"open_requests\": the Open reminder requests}.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "parameters": [
          {
            "name": "contact",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "The Marketing Contact (its email address)."
          },
          {
            "name": "events",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer"
            },
            "description": "How many of the latest events to return (at most 200)."
          }
        ]
      }
    },
    "/api/method/ffl_core.api.marketing.customer_card": {
      "post": {
        "tags": [
          "ffl_core"
        ],
        "summary": "The line the Customer form shows about a customer's marketing email.",
        "description": "Nothing (None) when marketing is off, the user may not read Marketing Contacts or the customer,\nor no marketing contact is linked to the customer.\n\n**Auth (derived from code):** Any authenticated user — no explicit role gate at function entry (deliberate open reads document this in Permissions).\n\nSource: `apps/ffl_core/ffl_core/api/marketing.py:79`",
        "operationId": "ffl_core.api.marketing.customer_card",
        "responses": {
          "200": {
            "description": "{\"status\": the contact's status, \"tags\": its tags, \"text\": the line to show, \"contact\": the Marketing Contact (its email address) to open}, or None.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": [
                        "object",
                        "null"
                      ]
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "customer": {
                    "type": "string",
                    "description": "The Customer's name."
                  }
                },
                "required": [
                  "customer"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_core.api.marketing.find_contacts": {
      "get": {
        "tags": [
          "ffl_core"
        ],
        "summary": "Find marketing contacts, newest first.",
        "description": "Any of the filters, together. Refused while marketing is switched off.\n\n**Auth (derived from code):** Requires read permission on Marketing Contact (Frappe DocType permission check).\n\nSource: `apps/ffl_core/ffl_core/api/marketing.py:122`",
        "operationId": "ffl_core.api.marketing.find_contacts",
        "responses": {
          "200": {
            "description": "{\"total\": how many contacts match, \"contacts\": [{email, first_name, last_name, status, source, consent_at, consent_channel, status_changed_at, status_reason, customer, creation, tags}]}.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "parameters": [
          {
            "name": "email",
            "in": "query",
            "required": false,
            "schema": {
              "type": [
                "string",
                "null"
              ]
            },
            "description": "Part of the email address."
          },
          {
            "name": "name",
            "in": "query",
            "required": false,
            "schema": {
              "type": [
                "string",
                "null"
              ]
            },
            "description": "Part of the first or last name."
          },
          {
            "name": "tag",
            "in": "query",
            "required": false,
            "schema": {
              "type": [
                "string",
                "null"
              ]
            },
            "description": "A tag the contact has (exact)."
          },
          {
            "name": "status",
            "in": "query",
            "required": false,
            "schema": {
              "type": [
                "string",
                "null"
              ]
            },
            "description": "Not Subscribed, Subscribed, Unsubscribed, Bounced or Complained."
          },
          {
            "name": "source",
            "in": "query",
            "required": false,
            "schema": {
              "type": [
                "string",
                "null"
              ]
            },
            "description": "Where the contact first came from; a prefix (\"fluentform\" matches \"fluentform:3\")."
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer"
            },
            "description": "How many to return (at most 200)."
          },
          {
            "name": "start",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer"
            },
            "description": "How many to skip, for the next page."
          }
        ]
      }
    },
    "/api/method/ffl_core.api.marketing.list_requests": {
      "get": {
        "tags": [
          "ffl_core"
        ],
        "summary": "Back-in-stock and model-alert reminder requests, newest first.",
        "description": "Refused while marketing is switched off.\n\n**Auth (derived from code):** Requires read permission on Marketing Request (Frappe DocType permission check).\n\nSource: `apps/ffl_core/ffl_core/api/marketing.py:259`",
        "operationId": "ffl_core.api.marketing.list_requests",
        "responses": {
          "200": {
            "description": "[{name, contact, kind, status, label, item, sku, web_product_id, model_key, url, requested_at, notified_at}].",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "array"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "parameters": [
          {
            "name": "status",
            "in": "query",
            "required": false,
            "schema": {
              "type": [
                "string",
                "null"
              ]
            },
            "description": "Open (the default), Notified or Closed; \"all\" for every status."
          },
          {
            "name": "kind",
            "in": "query",
            "required": false,
            "schema": {
              "type": [
                "string",
                "null"
              ]
            },
            "description": "Back in stock or Model alert."
          },
          {
            "name": "contact",
            "in": "query",
            "required": false,
            "schema": {
              "type": [
                "string",
                "null"
              ]
            },
            "description": "One contact's (its email address)."
          },
          {
            "name": "item",
            "in": "query",
            "required": false,
            "schema": {
              "type": [
                "string",
                "null"
              ]
            },
            "description": "The POS Item the request is for."
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer"
            },
            "description": "How many to return (at most 200)."
          },
          {
            "name": "start",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer"
            },
            "description": "How many to skip, for the next page."
          }
        ]
      }
    },
    "/api/method/ffl_core.api.marketing.record_consent": {
      "post": {
        "tags": [
          "ffl_core"
        ],
        "summary": "Record that a contact agreed to marketing email: Not Subscribed becomes Subscribed.",
        "description": "For a consent given outside the website (at the counter, on the phone, on a paper form). A contact\nthat unsubscribed, bounced or complained is refused: this never puts one back (a manager can, on\nthe contact's form, with a reason). Who recorded it, the channel and the note go on the log.\nRefused while marketing is switched off.\n\n**Auth (derived from code):** Roles: Marketing User / Sales Manager / System Manager\n\nSource: `apps/ffl_core/ffl_core/api/marketing.py:226`",
        "operationId": "ffl_core.api.marketing.record_consent",
        "responses": {
          "200": {
            "description": "{\"contact\": the address, \"status\": the status now, \"changed\": False when it was already Subscribed}.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "contact": {
                    "type": "string",
                    "description": "The Marketing Contact (its email address)."
                  },
                  "channel": {
                    "type": "string",
                    "description": "Where the consent was given, in a word or two (\"in store\", \"phone\")."
                  },
                  "note": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "description": "Anything worth keeping with it. Optional."
                  }
                },
                "required": [
                  "contact",
                  "channel"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_core.api.marketing.resubscribe": {
      "post": {
        "tags": [
          "ffl_core"
        ],
        "summary": "Put a suppressed contact back to Subscribed.",
        "description": "For a contact that unsubscribed, bounced or complained. The reason is required and goes on the log\nwith who did it.\n\n**Auth (derived from code):** Roles: Sales Manager / System Manager\n\nSource: `apps/ffl_core/ffl_core/api/marketing.py:57`",
        "operationId": "ffl_core.api.marketing.resubscribe",
        "responses": {
          "200": {
            "description": "{\"contact\": the address, \"status\": \"Subscribed\"}. Refused for a contact that is not suppressed.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "contact": {
                    "type": "string",
                    "description": "The Marketing Contact (its email address)."
                  },
                  "reason": {
                    "type": "string",
                    "description": "Why this contact may be emailed again."
                  }
                },
                "required": [
                  "contact",
                  "reason"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_core.api.marketing.tag_contact": {
      "post": {
        "tags": [
          "ffl_core"
        ],
        "summary": "Add tags to a marketing contact and take tags off it.",
        "description": "A tag is a slug (lowercase letters, digits and dashes); anything else is refused, nothing changed.\nTags never send anything. Refused while marketing is switched off.\n\n**Auth (derived from code):** Roles: Marketing User / Sales Manager / System Manager\n\nSource: `apps/ffl_core/ffl_core/api/marketing.py:197`",
        "operationId": "ffl_core.api.marketing.tag_contact",
        "responses": {
          "200": {
            "description": "{\"contact\": the address, \"added\": tags that were new to it, \"removed\": tags it had, \"tags\": its tags now}.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "contact": {
                    "type": "string",
                    "description": "The Marketing Contact (its email address)."
                  },
                  "add": {
                    "description": "Tags to add (a list, or a comma-separated string)."
                  },
                  "remove": {
                    "description": "Tags to take off."
                  }
                },
                "required": [
                  "contact"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_core.api.marketing.unsubscribe": {
      "post": {
        "tags": [
          "ffl_core"
        ],
        "summary": "Stop marketing email to a contact.",
        "description": "Its status becomes Unsubscribed, with who did it and the reason on the log. A contact already\nUnsubscribed, Bounced or Complained is left as it is.\n\n**Auth (derived from code):** Roles: Marketing User / Sales Manager / System Manager\n\nSource: `apps/ffl_core/ffl_core/api/marketing.py:35`",
        "operationId": "ffl_core.api.marketing.unsubscribe",
        "responses": {
          "200": {
            "description": "{\"contact\": the address, \"status\": the status now, \"changed\": False when it was already suppressed}.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "contact": {
                    "type": "string",
                    "description": "The Marketing Contact (its email address)."
                  },
                  "reason": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "description": "Why, in a few words. Optional."
                  }
                },
                "required": [
                  "contact"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_core.api.marketing_mail.send_test_email": {
      "post": {
        "tags": [
          "ffl_core"
        ],
        "summary": "Queue a test marketing email for the signed-in staff member, at their own address.",
        "description": "It goes the way every marketing email goes: the mail queue from the marketing Email Account, the\nList-Unsubscribe headers, tracking as Marketing Settings has it, and a working unsubscribe link\n(using it unsubscribes this address, and the next test is refused until a manager puts it back).\nThe mail queue sends it a moment later. Each call is its own campaign, so it can be queued again.\n\n**Auth (derived from code):** Roles: Sales Manager / System Manager\n\nSource: `apps/ffl_core/ffl_core/api/marketing_mail.py:17`",
        "operationId": "ffl_core.api.marketing_mail.send_test_email",
        "responses": {
          "200": {
            "description": "{\"queued\": true when it is in the mail queue, \"email\": the address, \"status\": that address's marketing status (a test is refused for an unsubscribed, bounced or complained one)}.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        }
      }
    },
    "/api/method/ffl_core.api.oauth_dcr.register_client": {
      "post": {
        "tags": [
          "webhooks"
        ],
        "summary": "RFC 7591 dynamic client registration (Frappe's), plus localhost loopback",
        "description": "redirects. Open by design like Frappe's: the client still needs a user to\nsign in and approve before it gets any token.\n\n**Auth (derived from code):** Guest — no session; the endpoint verifies the caller itself (HMAC signature, HTTP Basic credentials or a one-time token).\n\nSource: `apps/ffl_core/ffl_core/api/oauth_dcr.py:35`",
        "operationId": "ffl_core.api.oauth_dcr.register_client",
        "responses": {
          "200": {
            "description": "Frappe's registration response (201 with the client metadata, or 400)."
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "security": []
      }
    },
    "/api/method/ffl_core.api.pending_4473.alert_overdue_pending_4473": {
      "post": {
        "tags": [
          "ffl_core"
        ],
        "summary": "Raise a manager ToDo for every counter order whose 4473 was abandoned.",
        "description": "Scheduled daily. Alerts only — it never deletes a draft, never releases a\ngun and never calls FastBound: an abandoned 4473 leaves a pending\ndisposition in the bound book, and deleting one of those unattended is\nexactly the automation the owner refused.\n\nDeduped by ``ffl_core.alerts.alert_once``, so an order that stays abandoned\nis one ToDo on the invoice until a person closes it — not one per day.\n\n**Auth (derived from code):** Any authenticated user — no explicit role gate at function entry (deliberate open reads document this in Permissions).\n\n**Permissions:** Inventory roles (manual path; the scheduler runs as Administrator).\n\nSource: `apps/ffl_core/ffl_core/api/pending_4473.py:64`",
        "operationId": "ffl_core.api.pending_4473.alert_overdue_pending_4473",
        "responses": {
          "200": {
            "description": "``{overdue, alerted}`` — ``alerted`` counts only the NEW alerts; the difference is orders already carrying an open ToDo.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        }
      }
    },
    "/api/method/ffl_core.api.photos.add_gallery_images": {
      "post": {
        "tags": [
          "ffl_core"
        ],
        "summary": "Append already-uploaded photos to a document's gallery in ONE save.",
        "description": "**Auth (derived from code):** Any authenticated user — no explicit role gate at function entry (deliberate open reads document this in Permissions).\n\nSource: `apps/ffl_core/ffl_core/api/photos.py:121`",
        "operationId": "ffl_core.api.photos.add_gallery_images",
        "responses": {
          "200": {
            "description": "list[dict]: the gallery in publish order — ``name``, ``image``, ``is_primary``, ``sort_order``, ``caption`` per row.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "array"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "doctype": {
                    "type": "string",
                    "description": "``Item`` or ``Serial No``."
                  },
                  "name": {
                    "type": "string",
                    "description": "the document."
                  },
                  "file_urls": {
                    "type": "array",
                    "description": "``/files/...`` URLs of Files already on this site (the Frappe uploader creates them); a JSON string is accepted."
                  }
                },
                "required": [
                  "doctype",
                  "name",
                  "file_urls"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_core.api.photos.remove_gallery_image": {
      "post": {
        "tags": [
          "ffl_core"
        ],
        "summary": "Remove a photo from the gallery; delete the file only when nothing else uses it.",
        "description": "**Auth (derived from code):** Any authenticated user — no explicit role gate at function entry (deliberate open reads document this in Permissions).\n\nSource: `apps/ffl_core/ffl_core/api/photos.py:230`",
        "operationId": "ffl_core.api.photos.remove_gallery_image",
        "responses": {
          "200": {
            "description": "list[dict]: the remaining gallery in publish order.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "array"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "doctype": {
                    "type": "string",
                    "description": "``Item`` or ``Serial No``."
                  },
                  "name": {
                    "type": "string",
                    "description": "the document."
                  },
                  "row_name": {
                    "type": "string",
                    "description": "the gallery row to remove."
                  }
                },
                "required": [
                  "doctype",
                  "name",
                  "row_name"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_core.api.photos.reorder_gallery": {
      "post": {
        "tags": [
          "ffl_core"
        ],
        "summary": "Persist the order the operator dragged the photos into.",
        "description": "**Auth (derived from code):** Any authenticated user — no explicit role gate at function entry (deliberate open reads document this in Permissions).\n\nSource: `apps/ffl_core/ffl_core/api/photos.py:161`",
        "operationId": "ffl_core.api.photos.reorder_gallery",
        "responses": {
          "200": {
            "description": "list[dict]: the gallery in publish order (primary always first).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "array"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "doctype": {
                    "type": "string",
                    "description": "``Item`` or ``Serial No``."
                  },
                  "name": {
                    "type": "string",
                    "description": "the document."
                  },
                  "row_names": {
                    "type": "array",
                    "description": "every gallery row name, in the new order; JSON string accepted. Must be exactly the current set of rows."
                  }
                },
                "required": [
                  "doctype",
                  "name",
                  "row_names"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_core.api.photos.serials_for_item": {
      "post": {
        "tags": [
          "ffl_core"
        ],
        "summary": "The serials of one Item with their photo counts, for the upload-by-serial page.",
        "description": "**Auth (derived from code):** Requires read permission on Serial No (Frappe DocType permission check).\n\nSource: `apps/ffl_core/ffl_core/api/photos.py:265`",
        "operationId": "ffl_core.api.photos.serials_for_item",
        "responses": {
          "200": {
            "description": "list[dict]: per serial — ``serial_no``, ``status``, ``warehouse``, ``image``, ``photo_count``, ``thumbs`` (first few photo URLs in publish order). Newest serials first, capped at 500.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "array"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "item_code": {
                    "type": "string",
                    "description": "the Item."
                  },
                  "in_stock_only": {
                    "type": "integer",
                    "description": "1 = only ``status = Active`` serials (default), 0 = all.",
                    "default": 1
                  },
                  "search": {
                    "type": "string",
                    "description": "optional substring filter on the serial number.",
                    "default": ""
                  }
                },
                "required": [
                  "item_code"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_core.api.photos.set_image_caption": {
      "post": {
        "tags": [
          "ffl_core"
        ],
        "summary": "Set a photo's caption (also used as its alt text).",
        "description": "**Auth (derived from code):** Any authenticated user — no explicit role gate at function entry (deliberate open reads document this in Permissions).\n\nSource: `apps/ffl_core/ffl_core/api/photos.py:210`",
        "operationId": "ffl_core.api.photos.set_image_caption",
        "responses": {
          "200": {
            "description": "list[dict]: the gallery in publish order.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "array"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "doctype": {
                    "type": "string",
                    "description": "``Item`` or ``Serial No``."
                  },
                  "name": {
                    "type": "string",
                    "description": "the document."
                  },
                  "row_name": {
                    "type": "string",
                    "description": "the gallery row."
                  },
                  "caption": {
                    "type": "string",
                    "description": "the new caption; blank clears it.",
                    "default": ""
                  }
                },
                "required": [
                  "doctype",
                  "name",
                  "row_name"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_core.api.photos.set_primary_image": {
      "post": {
        "tags": [
          "ffl_core"
        ],
        "summary": "Make one gallery photo the featured image.",
        "description": "**Auth (derived from code):** Any authenticated user — no explicit role gate at function entry (deliberate open reads document this in Permissions).\n\nSource: `apps/ffl_core/ffl_core/api/photos.py:187`",
        "operationId": "ffl_core.api.photos.set_primary_image",
        "responses": {
          "200": {
            "description": "list[dict]: the gallery in publish order; exactly one row is primary and the document's ``image`` mirrors it.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "array"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "doctype": {
                    "type": "string",
                    "description": "``Item`` or ``Serial No``."
                  },
                  "name": {
                    "type": "string",
                    "description": "the document."
                  },
                  "row_name": {
                    "type": "string",
                    "description": "the gallery row to feature."
                  }
                },
                "required": [
                  "doctype",
                  "name",
                  "row_name"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_core.api.pos_close.auto_close_open_pos": {
      "post": {
        "tags": [
          "ffl_core"
        ],
        "summary": "Auto-close every stale open POS shift, WITHOUT counting the drawer.",
        "description": "Finds every unclosed POS Opening Entry older than min_age_hours and\nsubmits a matching POS Closing Entry (card and other tenders trusted:\nclosing amount = expected amount; the Cash row repeats the cash ledger,\nflagged not counted). Then leaves an uncounted Cash Drawer Close for the\nday in every company that has a POS Profile, unless staff already counted\ntoday. Nothing is booked for the drawer. Runs nightly from the scheduler;\nwhitelisted for a manual force-close.\n\n**Auth (derived from code):** Roles: Sales Manager / Stock Manager / System Manager\n\n**Permissions:** Sales Manager / Stock Manager / System Manager.\n\nSource: `apps/ffl_core/ffl_core/api/pos_close.py:45`",
        "operationId": "ffl_core.api.pos_close.auto_close_open_pos",
        "responses": {
          "200": {
            "description": "{closed: [{opening, closing, grand_total}], skipped: [...], errors: [...], cash_drawer: [Cash Drawer Close names left uncounted], total_open_at_start, min_age_hours, ran_at}.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "min_age_hours": {
                    "type": [
                      "integer",
                      "null"
                    ],
                    "description": "Minimum opening age to close (default 1)."
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_core.api.pos_consolidate.consolidate_pos_invoice_now": {
      "post": {
        "tags": [
          "ffl_core"
        ],
        "summary": "Consolidate one submitted POS Invoice immediately (out-of-band).",
        "description": "Out-of-band from the POS closing batch, so its stock + Sales Invoice\npost now — a sold serialized gun must leave stock at sale, not at the\nnightly close. Idempotent: no-ops if the invoice is missing, not\nsubmitted, already consolidated, or a return whose original sale is\nnot yet consolidated (a return becomes a credit note against the\noriginal's consolidated Sales Invoice, so the original must go first —\nthe sweep orders them that way; see reconsolidate_stuck_pos_invoices).\nA merge that loses a row race to a concurrent write, or times out waiting\nfor a lock, is rolled back and run again: 3 attempts in all.\n\n**Auth (derived from code):** Roles: Sales User / Sales Manager / Stock Manager / System Manager\n\n**Permissions:** Sales User / Sales Manager / Stock Manager / System Manager.\n\nSource: `apps/ffl_core/ffl_core/api/pos_consolidate.py:71`",
        "operationId": "ffl_core.api.pos_consolidate.consolidate_pos_invoice_now",
        "responses": {
          "200": {
            "description": "{consolidated: bool, pos_invoice, [sales_invoice]}.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "pos_invoice": {
                    "type": "string",
                    "description": "Submitted POS Invoice name."
                  }
                },
                "required": [
                  "pos_invoice"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_core.api.pos_consolidate.reconsolidate_stuck_pos_invoices": {
      "post": {
        "tags": [
          "ffl_core"
        ],
        "summary": "Retry every submitted POS Invoice that never consolidated (the sweep).",
        "description": "Covers two ways a sale gets stranded: a firearm invoice whose immediate\non-submit consolidation failed (always swept, never capped), and any\ninvoice — returns included — from the last 30 days that the nightly\nPOS close left behind (the close is owner-scoped, so a sale rung up by\na clerk other than the shift opener is skipped — see\n_find_stuck_pos_invoices). The missed-close part works in batches of\n50 per run, originals before their returns, invoices already carrying\na stuck ToDo last; idempotent per invoice (consolidate_pos_invoice_now\nno-ops the already-done ones). A failure is logged AND surfaced as a\nToDo (at most 5 new ToDos per run, plus one summary log when more\nfailed); a return held for an original the sweep can never reach is\nsurfaced the same way. Each run then closes those ToDos for every\ninvoice that has merged since, however it merged. Runs from the\nscheduler (hooks.scheduler_events) and is whitelisted for an on-demand\nsweep.\n\n**Auth (derived from code):** Roles: Sales Manager / Stock Manager / System Manager\n\n**Permissions:** Sales Manager / Stock Manager / System Manager.\n\nSource: `apps/ffl_core/ffl_core/api/pos_consolidate.py:246`",
        "operationId": "ffl_core.api.pos_consolidate.reconsolidate_stuck_pos_invoices",
        "responses": {
          "200": {
            "description": "{checked, consolidated: [names], failed: [names], held: [names]} — held = returns waiting for their original to consolidate first.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "older_than_minutes": {
                    "type": [
                      "integer",
                      "null"
                    ],
                    "description": "Only sweep invoices older than this settle window (default 10), so the sweep never races the on-submit enqueue on a fresh sale."
                  },
                  "batch": {
                    "type": [
                      "integer",
                      "null"
                    ],
                    "description": "Missed-close invoices to take this run (default 50, clamped to 1–500) — for a manual sweep of a known backlog."
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_core.api.pos_order_status.draft_order_status": {
      "get": {
        "tags": [
          "ffl_core"
        ],
        "summary": "Payment and 4473 facts for a page of draft POS Invoices.",
        "description": "**Auth (derived from code):** Requires read permission on POS Invoice (Frappe DocType permission check).\n\nSource: `apps/ffl_core/ffl_core/api/pos_order_status.py:25`",
        "operationId": "ffl_core.api.pos_order_status.draft_order_status",
        "responses": {
          "200": {
            "description": "{name: {\"due\", \"currency\", \"paid_amount\", \"charged\", \"card_status\", \"held\", \"paid_online\", \"payments\": [{\"mode_of_payment\", \"amount\"}], \"counter_order\": {\"name\", \"total\", \"outstanding\"} | None, \"has_firearm\", \"form_4473_status\", \"nics_status\"}} for each name that is a draft, non-return POS Invoice the caller can read. Any other name is left out. counter_order is the money side of a counter pickup's 4473 ticket — the Sales Invoice it hands over for (the ticket itself carries $0).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "parameters": [
          {
            "name": "invoices",
            "in": "query",
            "required": true,
            "schema": {
              "type": "array"
            },
            "description": "POS Invoice names — a list, a JSON-encoded list, or one name. Duplicates are ignored; at most 100 names are read."
          }
        ]
      }
    },
    "/api/method/ffl_core.api.pos_recycle_bin.list_deleted_invoices": {
      "post": {
        "tags": [
          "ffl_core"
        ],
        "summary": "Deleted POS Invoice drafts that can still be restored, newest first.",
        "description": "Backs the \"Deleted\" filter of the POS Recent Orders list. Reads the\nDeleted Document log directly (that doctype is System Manager only — the\ngate here is the caller's POS Invoice permission instead).\n\n**Auth (derived from code):** Requires delete permission on POS Invoice (Frappe DocType permission check).\n\nSource: `apps/ffl_core/ffl_core/api/pos_recycle_bin.py:111`",
        "operationId": "ffl_core.api.pos_recycle_bin.list_deleted_invoices",
        "responses": {
          "200": {
            "description": "List of dicts: deleted_document (log row id to pass to restore_deleted_invoice), name (original invoice number), customer_name, grand_total, currency, posting_date, posting_time, is_return, deleted_by, deleted_at."
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "search_term": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "description": "Optional substring matched case-insensitively against the original invoice number and the customer name."
                  },
                  "days": {
                    "type": [
                      "integer",
                      "null"
                    ],
                    "description": "Look-back window in days (default 30, max 365)."
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_core.api.pos_recycle_bin.restore_deleted_invoice": {
      "post": {
        "tags": [
          "ffl_core"
        ],
        "summary": "Put a deleted POS Invoice draft back, keeping its original number when free.",
        "description": "Re-inserts the logged JSON with `flags.from_restore` (so the card charge\nprotector keeps the invoice's own card rows — see\nffl_integrations.payments.api.restore_charge_rows), retains the original\nowner / timestamps like frappe's own restore, and marks the log row\nrestored. Validation runs as on any insert: a serial sold in the meantime\nmakes the restore fail loudly instead of creating a double sale.\n\n**Auth (derived from code):** Requires delete permission on POS Invoice (Frappe DocType permission check).\n\nSource: `apps/ffl_core/ffl_core/api/pos_recycle_bin.py:161`",
        "operationId": "ffl_core.api.pos_recycle_bin.restore_deleted_invoice",
        "responses": {
          "200": {
            "description": "Dict with name (the restored invoice's number), original_name, and renamed (True when the original number was already taken and the naming series assigned a new one)."
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "name": {
                    "type": "string",
                    "description": "Deleted Document row id (from list_deleted_invoices)."
                  }
                },
                "required": [
                  "name"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_core.api.pos_serial.get_pos_reserved_serial_nos": {
      "post": {
        "tags": [
          "ffl_core"
        ],
        "summary": "Serials held by submitted, not-yet-consolidated POS Invoices (override).",
        "description": "Replaces ERPNext's serial_no.get_pos_reserved_serial_nos for the POS\npage's add-to-cart check. Same result as upstream, except a POS Invoice\nthat has been consolidated into a Sales Invoice no longer reserves its\nserials: the stock ledger already reflects that sale.\n\n**Auth (derived from code):** Requires read permission on POS Invoice (Frappe DocType permission check).\n\n**Permissions:** Same gates as upstream: POS Invoice read, and select on the warehouse.\n\nSource: `apps/ffl_core/ffl_core/api/pos_serial.py:25`",
        "operationId": "ffl_core.api.pos_serial.get_pos_reserved_serial_nos",
        "responses": {
          "200": {
            "description": "List of serial numbers reserved by open POS tickets, net of open return tickets."
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "filters": {
                    "description": "Dict (or JSON string) with item_code and warehouse."
                  }
                },
                "required": [
                  "filters"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_core.api.pos_session.check_opening_entry": {
      "post": {
        "tags": [
          "ffl_core"
        ],
        "summary": "Resolve the POS opening entry for a shared register (override).",
        "description": "Replaces ERPNext's point_of_sale.check_opening_entry (wired via\noverride_whitelisted_methods): keeps the native behavior when the user\nhas their own open entry, and otherwise falls back to ANY open entry —\none register, one shift, many clerks (see module docstring for the\ndeadlock this solves).\n\n**Auth (derived from code):** Any authenticated user — no explicit role gate at function entry (deliberate open reads document this in Permissions).\n\n**Permissions:** Open by design (endpoint-gates adjudication group A): ERPNext's own check_opening_entry is gateless, and this override must keep upstream's semantics — any clerk resuming the shared register calls it before a shift/role context exists.\n\nSource: `apps/ffl_core/ffl_core/api/pos_session.py:25`",
        "operationId": "ffl_core.api.pos_session.check_opening_entry",
        "responses": {
          "200": {
            "description": "List of open POS Opening Entry rows ({name, company, pos_profile, period_start_date}), the caller's own first."
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "user": {
                    "description": "Session user the POS page is resolving a shift for."
                  }
                },
                "required": [
                  "user"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_core.api.pos_ticket.open_ticket": {
      "post": {
        "tags": [
          "ffl_core"
        ],
        "summary": "Open a draft register ticket (POS Invoice) on the open POS shift.",
        "description": "A rate under the line's list price needs a manager's approval while the store requires one,\nas at the register: a manager signed in approves their own; anyone else sends the token a\nmanager's approval gave for this ticket. A rate past the item's Max Discount is refused. The\ncustomer's member price, worked out here, is the system's and asks nothing; a typed rate under\nit asks like any other.\n\n**Auth (derived from code):** Roles: Sales User / Sales Manager / Stock Manager / System Manager\n\nSource: `apps/ffl_core/ffl_core/api/pos_ticket.py:123`",
        "operationId": "ffl_core.api.pos_ticket.open_ticket",
        "responses": {
          "200": {
            "description": "{\"pos_invoice\", \"grand_total\", \"payment_modes\": the profile's modes of payment on the ticket}. Refused when no shift is open, or when a lowered price has no approval.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "customer": {
                    "type": "string",
                    "description": "Customer name."
                  },
                  "items": {
                    "description": "JSON list of lines ``[{item_code, qty=1, rate?, serial_no?, storage_location?}]``; rate blank = the item's price for the customer, a serial is one unit. A member price lower than the line's rate replaces it."
                  },
                  "company": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "description": "Company the shift is on; blank = the user's default company."
                  },
                  "approval_token": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "description": "The token ``ffl_core.price_approval.approve`` returned for this ticket (its doc: a POS Invoice with these customer and lines)."
                  }
                },
                "required": [
                  "customer",
                  "items"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_core.api.receive_goods.create_item": {
      "post": {
        "tags": [
          "ffl_core"
        ],
        "summary": "Quick-create an Item from the Receive Goods page, then return the",
        "description": "same shape as `lookup_item` so the caller can drop the result straight\ninto the pending card.\n\n**Auth (derived from code):** Roles: Stock Manager / System Manager\n\n**Permissions:** Stock Manager / System Manager.\n\nSource: `apps/ffl_core/ffl_core/api/receive_goods.py:899`",
        "operationId": "ffl_core.api.receive_goods.create_item",
        "responses": {
          "200": {
            "description": "Same shape as lookup_item's successful response.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "payload": {
                    "description": "Dict or JSON string. Required: item_code, item_group. Optional: item_name (defaults to item_code), has_serial_no (0), stock_uom (defaults to \"Nos\"), standard_rate, barcode, uniform_sell_price, is_antique (GCA-exempt marker)."
                  }
                },
                "required": [
                  "payload"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_core.api.receive_goods.create_receive": {
      "post": {
        "tags": [
          "ffl_core"
        ],
        "summary": "Build + insert + submit a Purchase Receipt from the page's payload.",
        "description": "`payload` arrives as a JSON string when called via frappe.call from the\nbrowser; accept dicts too for internal Python callers.\n\nSchema:\n        {\n                \"supplier\": \"ACME-FFL\",\n                \"source\": \"RSR\",                       # required — internal procurement channel\n                \"acquisition_type\": \"Purchase\",        # optional — FastBound bound-book acquisition type\n                \"posting_date\": \"2026-05-05\",          # optional, defaults to today\n                \"posting_time\": \"14:30:00\",            # optional, defaults to now\n                \"warehouse\": \"Main - GS\",              # optional, defaults to company default\n                \"notes\": \"...\",                        # optional\n                \"items\": [\n                        {\"item_code\": \"X\", \"qty\": 100, \"rate\": 0.50, \"serials\": [], \"service_need\": 0},\n                        {\"item_code\": \"FIREARM-A\", \"qty\": 1, \"rate\": 500, \"serials\": [\"A001\"],\n                         \"service_need\": 1, \"manufacturer\": \"Glock\", \"model_name\": \"19\",\n                         \"firearm_type\": \"Pistol\", \"caliber\": \"9mm\", \"importer\": \"\"},\n                        {\"item_code\": \"FIREARM-B\", \"qty\": 1, \"rate\": 0, \"serials\": [\"B001\"],\n                         \"zero_cost_confirmed\": 1, \"zero_cost_reason\": \"Supplier gift\",\n                         \"zero_cost_note\": \"\", \"manufacturer\": \"...\", \"model_name\": \"...\"}\n                ]\n        }\n\nAny line may carry ``storage_location`` (a Storage Location name): where the\nunits are put in the store. A firearm line with several serials fills that slot and\nthe next free ones in the same zone; ``serial_locations`` ({serial: location})\noverrides it per gun. A line with no location lands in \"unassigned\" on the\nStorage Locations page. Ignored for a customer-custody receive.\n\n`rate` is REQUIRED on every line except a customer-custody receipt\n(is_ffl_transfer, forced to 0 here) and a consignor's stock\n(acquisition_type=\"Consignment\", legitimately $0). A missing rate and a\nrate of 0 are NOT the same thing and neither is accepted silently: an\nacquisition that really was free must say so with `zero_cost_confirmed: 1`\nplus a `zero_cost_reason` from ffl_core.setup.zero_cost.ZERO_COST_REASONS\n(\"Supplier gift\" / \"Promotional item\" / \"Warranty replacement\" / \"Sample\" /\n\"Other\"), and \"Other\" additionally requires a free-text `zero_cost_note`.\nThe trio lands on the Purchase Receipt Item (ffl_-prefixed) and, for\nfirearms, on each Serial No.\n\nValidation here is minimal — server-side hooks (validate, on_submit)\nenforce the FFL gate + Used Firearm qty=1 + Acquisition creation.\n\nA purchase from a private seller (``acquisition_source`` \"Individual\")\nthat costs anything says how the seller was paid: ``seller_payment_method``\n(Cash / Zelle / Check / ACH) and, unless Cash, ``seller_payment_reference``\n(check number, Zelle confirmation, ACH reference). Whether and how much is\npaid is one decision (``cash_drawer.seller_payment_at_receipt``), the same\none ``seller_payment_preview`` gives the page before Submit. The payment is\nbooked in the receive's transaction BEFORE the bound-book push, and the\ndrawer lock is taken first, before any stock is written, with a bounded\nwait (the same lock order as a count, so the two never deadlock): nothing\nthat can fail runs after FastBound has the acquisition, and a push that\nfails rolls the payment back with the receipt. The amount booked must be\nthe amount the dialog showed, or the receive is refused before the push. Dr Stock Received But Not Billed / Cr Cash, or the bank account,\ndated today (``cash_drawer.record_goods_payout``). It covers every line, the guns\nincluded. Which receipts pay: ``cash_drawer.receipt_pays_seller`` (the\nacquisition type blank, \"Purchase\" or \"Individual\"); a Consignment,\nGunsmithing or transfer receipt, a customer-custody one and a dealer\npurchase pay nobody here, and a method sent for one is ignored.\n\n**Auth (derived from code):** Roles: Stock Manager / System Manager\n\n**Permissions:** Stock Manager / System Manager.\n\nSource: `apps/ffl_core/ffl_core/api/receive_goods.py:132`",
        "operationId": "ffl_core.api.receive_goods.create_receive",
        "responses": {
          "200": {
            "description": "{ok: True, name: <Purchase Receipt>, total: <grand total>, seller_payment: {entry, journal_entry, amount, method, reference, excluded} or None when nobody was paid here}.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "payload": {
                    "description": "See Schema above — dict or JSON string."
                  },
                  "before_push": {
                    "description": "Internal callers only: a callable run in the receive's transaction just before the bound-book push (a whitelisted call's arguments are never callable)."
                  }
                },
                "required": [
                  "payload"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_core.api.receive_goods.get_receive_sources": {
      "post": {
        "tags": [
          "ffl_core"
        ],
        "summary": "Source dropdown values for Receive Goods + FFL Acquisition + Purchase",
        "description": "Receipt.\n\nAdmin-edited in FFL Settings → Receive Sources (one per line).\n\n**Auth (derived from code):** Roles: Sales User / Sales Manager / Stock Manager / System Manager\n\nSource: `apps/ffl_core/ffl_core/api/receive_goods.py:1091`",
        "operationId": "ffl_core.api.receive_goods.get_receive_sources",
        "responses": {
          "200": {
            "description": "List of source strings, in configured order.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "array"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        }
      }
    },
    "/api/method/ffl_core.api.receive_goods.lookup_item": {
      "post": {
        "tags": [
          "ffl_core"
        ],
        "summary": "Resolve a barcode or item code → item info dict.",
        "description": "Tries the Item Barcode child table first, then Item code.\n\n**Auth (derived from code):** Roles: Sales User / Sales Manager / Stock Manager / System Manager\n\nSource: `apps/ffl_core/ffl_core/api/receive_goods.py:54`",
        "operationId": "ffl_core.api.receive_goods.lookup_item",
        "responses": {
          "200": {
            "description": "{found: bool, item_code, item_name, item_group, has_serial_no, is_firearm, is_antique, antique_locked, last_rate, stock_uom, standard_rate, uniform_sell_price, dealer_price, ...} plus, for firearms, the firearm detail fields (manufacturer, model_name, caliber, firearm_type, year_made — importer is never returned: it is a per-gun marking stated at receive, not an Item default).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "scan": {
                    "type": "string",
                    "description": "Scanned barcode or typed item code."
                  }
                },
                "required": [
                  "scan"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_core.api.receive_goods.search_items": {
      "post": {
        "tags": [
          "ffl_core"
        ],
        "summary": "Typeahead search across Item.barcode, Item.item_code (SKU), Item.item_name.",
        "description": "Ordering: exact barcode / item_code matches first, then LIKE matches\nranked by item_name. Disabled items excluded.\n\n**Auth (derived from code):** Roles: Sales User / Sales Manager / Stock Manager / System Manager\n\nSource: `apps/ffl_core/ffl_core/api/receive_goods.py:809`",
        "operationId": "ffl_core.api.receive_goods.search_items",
        "responses": {
          "200": {
            "description": "Up to `limit` rows with the same shape as `lookup_item`'s successful response (minus the `found` flag), so the JS can hand a picked row directly to the pending-card builder.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "array"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "query": {
                    "type": "string",
                    "description": "Substring to match (blank returns [])."
                  },
                  "limit": {
                    "type": "integer",
                    "description": "Row cap, clamped to 1–50 (default 10).",
                    "default": 10
                  }
                },
                "required": [
                  "query"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_core.api.receive_goods.seller_payment_preview": {
      "post": {
        "tags": [
          "ffl_core"
        ],
        "summary": "What Submit will pay the private seller, before anything is written: the Pay the seller dialog shows exactly",
        "description": "what the receipt will book (the same rule and amount as create_receive).\n\n**Auth (derived from code):** Roles: Stock Manager / System Manager\n\nSource: `apps/ffl_core/ffl_core/api/receive_goods.py:743`",
        "operationId": "ffl_core.api.receive_goods.seller_payment_preview",
        "responses": {
          "200": {
            "description": "{pays, amount, methods}; pays is false when nobody is paid at receipt (a dealer, Consignment, Gunsmithing or transfer receipt, or nothing costs anything); methods are the ways a seller can be paid.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "payload": {
                    "description": "The create_receive payload (dict or JSON string); only the acquisition source / type, the transfer markers and the lines are read."
                  }
                },
                "required": [
                  "payload"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_core.api.return_in_transit.return_in_transit": {
      "post": {
        "tags": [
          "ffl_core"
        ],
        "summary": "Undo a shipped transfer the carrier returned: cancel the disposition, receive the gun back.",
        "description": "The FFL Disposition is cancelled (its on_cancel deletes the FastBound record and\nundisposes the item) and a Material Receipt dated today brings the gun back into\nthe warehouse it left, at the value and offset account of the disposition's\nMaterial Issue, with remarks naming both. The issue itself stays submitted.\n\n**Auth (derived from code):** Roles: Sales Manager / Stock Manager / System Manager\n\n**Permissions:** Managers only.\n\nSource: `apps/ffl_core/ffl_core/api/return_in_transit.py:56`",
        "operationId": "ffl_core.api.return_in_transit.return_in_transit",
        "responses": {
          "200": {
            "description": "{\"ok\": True, \"disposition\", \"serial\", \"stock_entry\" (the receipt), \"issue\" (the original Material Issue), \"fastbound\": \"undispose_queued\" | \"not_pushed\" | \"disabled\", \"sale\": {\"doctype\", \"name\"} | None, \"next_step\": str | None}. next_step says what the linked sale still needs (a counter order is back on the Pending Order queue).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "disposition": {
                    "type": "string",
                    "description": "Submitted FFL Disposition (FFL Transfer, Dealer Transfer or Return) whose own Material Issue took the gun out of stock."
                  }
                },
                "required": [
                  "disposition"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_core.api.serial_correction.correct_serial": {
      "post": {
        "tags": [
          "ffl_core"
        ],
        "summary": "Rename an in-stock firearm's serial and sync FastBound, atomically.",
        "description": "All validation runs before any write; a FastBound failure rolls\neverything back.\n\n**Auth (derived from code):** Roles: Stock Manager / System Manager\n\n**Permissions:** Stock Manager / System Manager (aligned with intake).\n\nSource: `apps/ffl_core/ffl_core/api/serial_correction.py:45`",
        "operationId": "ffl_core.api.serial_correction.correct_serial",
        "responses": {
          "200": {
            "description": "{ok, old_serial, new_serial, ledger_serial, fastbound_item_id} — new_serial is the gun's Serial No name afterwards (the corrected serial itself, or a tagged key when another gun already has that serial); fastbound_item_id is \"\" on a store running with the FastBound integration switched off, where the local rename is the whole correction.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "serial": {
                    "type": "string",
                    "description": "Current Serial No name (must be an in-stock firearm)."
                  },
                  "new_serial": {
                    "type": "string",
                    "description": "Corrected serial number, as the bound book should record it."
                  },
                  "reason": {
                    "type": "string",
                    "description": "Required free-text audit reason."
                  }
                },
                "required": [
                  "serial",
                  "new_serial",
                  "reason"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_core.api.storage.add_positions": {
      "post": {
        "tags": [
          "ffl_core"
        ],
        "summary": "Add slots to the end of a Slots zone (existing ones are never renumbered). An Open zone",
        "description": "is one location, so this is refused for it.\n\n**Auth (derived from code):** Roles: Stock Manager / System Manager\n\nSource: `apps/ffl_core/ffl_core/api/storage.py:492`",
        "operationId": "ffl_core.api.storage.add_positions",
        "responses": {
          "200": {
            "description": "{zone, positions, added}.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "zone": {
                    "type": "string",
                    "description": "The Storage Zone name."
                  },
                  "count": {
                    "type": "integer",
                    "description": "How many to add."
                  }
                },
                "required": [
                  "zone",
                  "count"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_core.api.storage.confirm_taken": {
      "post": {
        "tags": [
          "ffl_core"
        ],
        "summary": "Resolve a \"to confirm\" item: say which location sold or shipped units really",
        "description": "came from. They leave that location; stock and the books are untouched.\n\n**Auth (derived from code):** Roles: Sales User / Sales Manager / Stock User / Stock Manager / System Manager\n\nSource: `apps/ffl_core/ffl_core/api/storage.py:415`",
        "operationId": "ffl_core.api.storage.confirm_taken",
        "responses": {
          "200": {
            "description": "{ok: True, move, over}, where ``over`` is how many are still to confirm.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "item_code": {
                    "type": "string",
                    "description": "The non-serialized item."
                  },
                  "location": {
                    "type": "string",
                    "description": "The location they were taken from."
                  },
                  "qty": {
                    "type": "number",
                    "description": "How many."
                  },
                  "company": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "description": "Company; defaults to the user's company."
                  }
                },
                "required": [
                  "item_code",
                  "location",
                  "qty"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_core.api.storage.create_floor_plan": {
      "post": {
        "tags": [
          "ffl_core"
        ],
        "summary": "Start an empty floor plan for one room or floor of the store.",
        "description": "**Auth (derived from code):** Roles: Stock Manager / System Manager\n\nSource: `apps/ffl_core/ffl_core/api/storage.py:561`",
        "operationId": "ffl_core.api.storage.create_floor_plan",
        "responses": {
          "200": {
            "description": "{plan, modified}.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "plan_name": {
                    "type": "string",
                    "description": "Name shown on the plan's tab, like Showroom or Back Room."
                  },
                  "width": {
                    "type": "number",
                    "description": "Width of the room in feet.",
                    "default": 60
                  },
                  "height": {
                    "type": "number",
                    "description": "Depth of the room in feet.",
                    "default": 40
                  },
                  "company": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "description": "Company; defaults to the user's company."
                  }
                },
                "required": [
                  "plan_name"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_core.api.storage.create_zone": {
      "post": {
        "tags": [
          "ffl_core"
        ],
        "summary": "Create a zone and its positions. A Slots zone names them A1, A2, ... (one firearm",
        "description": "each). An Open zone is ONE location named like the zone (Rack 1: no limit, holds\nfirearms and everything else); create one zone per rack, case or safe.\n\n**Auth (derived from code):** Roles: Stock Manager / System Manager\n\nSource: `apps/ffl_core/ffl_core/api/storage.py:448`",
        "operationId": "ffl_core.api.storage.create_zone",
        "responses": {
          "200": {
            "description": "{zone, positions}.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "zone_name": {
                    "type": "string",
                    "description": "Short name, like A or Display Case."
                  },
                  "kind": {
                    "type": "string",
                    "description": "Slots or Open."
                  },
                  "count": {
                    "type": "integer",
                    "description": "How many slots to create in a Slots zone (ignored for Open, which is one location).",
                    "default": 1
                  },
                  "company": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "description": "Company; defaults to the user's company."
                  },
                  "sides": {
                    "type": "integer",
                    "description": "Slots only: how many sides (lines of slots) it has on the map, 1-50; a two-sided rack is 2. 0 (default) fits them to the shape it is drawn as.",
                    "default": 0
                  },
                  "numbering": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "description": "Slots with two sides: \"Odd / even\" (default: 1, 3, 5 ... down one side, 2, 4, 6 ... facing them) or \"In order\" (1, 2, 3 ... down the first side, then the second). One side or three and more always count in order."
                  }
                },
                "required": [
                  "zone_name",
                  "kind"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_core.api.storage.delete_floor_plan": {
      "post": {
        "tags": [
          "ffl_core"
        ],
        "summary": "Delete a floor plan. Its zones stay as they are, just on no plan.",
        "description": "**Auth (derived from code):** Roles: Stock Manager / System Manager\n\nSource: `apps/ffl_core/ffl_core/api/storage.py:607`",
        "operationId": "ffl_core.api.storage.delete_floor_plan",
        "responses": {
          "200": {
            "description": "{plan}.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "plan": {
                    "type": "string",
                    "description": "The Storage Floor Plan name."
                  },
                  "company": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "description": "The plan's company; defaults to the user's company."
                  }
                },
                "required": [
                  "plan"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_core.api.storage.delete_zone": {
      "post": {
        "tags": [
          "ffl_core"
        ],
        "summary": "Delete a zone and all its positions, and take it off its floor plan. Everything in",
        "description": "it must be moved out first.\n\n**Auth (derived from code):** Roles: Stock Manager / System Manager\n\nSource: `apps/ffl_core/ffl_core/api/storage.py:524`",
        "operationId": "ffl_core.api.storage.delete_zone",
        "responses": {
          "200": {
            "description": "{zone, removed}.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "zone": {
                    "type": "string",
                    "description": "The Storage Zone name."
                  },
                  "company": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "description": "The zone's company; defaults to the user's company."
                  }
                },
                "required": [
                  "zone"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_core.api.storage.get_location": {
      "post": {
        "tags": [
          "ffl_core"
        ],
        "summary": "What is in one location.",
        "description": "**Auth (derived from code):** Roles: Sales User / Sales Manager / Stock User / Stock Manager / System Manager\n\nSource: `apps/ffl_core/ffl_core/api/storage.py:213`",
        "operationId": "ffl_core.api.storage.get_location",
        "responses": {
          "200": {
            "description": "{location: {name, label, zone, kind, disabled}, guns: [{serial, item_code, item_name, manufacturer, model_name, caliber}], items: [{item_code, item_name, qty}]}.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "location": {
                    "type": "string",
                    "description": "A Storage Location name (or its barcode, which is the same)."
                  }
                },
                "required": [
                  "location"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_core.api.storage.get_map": {
      "post": {
        "tags": [
          "ffl_core"
        ],
        "summary": "The store map: every zone with each position's contents.",
        "description": "**Auth (derived from code):** Roles: Sales User / Sales Manager / Stock User / Stock Manager / System Manager\n\nSource: `apps/ffl_core/ffl_core/api/storage.py:157`",
        "operationId": "ffl_core.api.storage.get_map",
        "responses": {
          "200": {
            "description": "{company, zones: [{name, zone_name, kind, disabled, slot_lines, numbering, positions, used, locations: [{name, label, position, disabled, guns: [{serial, item_name}], qty, items}]}], plans: [{name, plan_name, width, height, modified, layout: {shapes: [{type, zone?, text?, x, y, w, h, r, rows?}]}}], unassigned: {guns, items, to_confirm}}. ``used`` counts positions holding a gun (Slots) or anything (Open, which has one). ``plans`` are the floor plans (one per room, in feet; x/y is a shape's centre, r its rotation in degrees); every zone shape names a zone in ``zones``.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "company": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "description": "Company to show; defaults to the user's company."
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_core.api.storage.get_options": {
      "post": {
        "tags": [
          "ffl_core"
        ],
        "summary": "What the Storage Locations page needs to start: the company, its zones and",
        "description": "whether the user may create or disable them.\n\n**Auth (derived from code):** Roles: Sales User / Sales Manager / Stock User / Stock Manager / System Manager\n\nSource: `apps/ffl_core/ffl_core/api/storage.py:42`",
        "operationId": "ffl_core.api.storage.get_options",
        "responses": {
          "200": {
            "description": "{company, can_manage, zones: [{name, zone_name, kind, disabled, positions}]}.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "company": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "description": "Company to show; defaults to the user's company."
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_core.api.storage.get_unassigned": {
      "post": {
        "tags": [
          "ffl_core"
        ],
        "summary": "Everything not in a location yet, and everything the locations over-claim.",
        "description": "**Auth (derived from code):** Roles: Sales User / Sales Manager / Stock User / Stock Manager / System Manager\n\nSource: `apps/ffl_core/ffl_core/api/storage.py:259`",
        "operationId": "ffl_core.api.storage.get_unassigned",
        "responses": {
          "200": {
            "description": "{guns: [{serial, item_code, item_name, ...}], items: [{item_code, item_name, stock, located, unassigned}], to_confirm: [{item_code, item_name, stock, located, over}]}. ``to_confirm`` lists items sold or shipped without saying which location they came from.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "company": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "description": "Company; defaults to the user's company."
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_core.api.storage.list_locations": {
      "post": {
        "tags": [
          "ffl_core"
        ],
        "summary": "Every location, for pickers and the label printer.",
        "description": "**Auth (derived from code):** Roles: Sales User / Sales Manager / Stock User / Stock Manager / System Manager\n\nSource: `apps/ffl_core/ffl_core/api/storage.py:62`",
        "operationId": "ffl_core.api.storage.list_locations",
        "responses": {
          "200": {
            "description": "[{name, label, zone, kind, position, disabled, free}] in zone and position order. ``free`` is true for a Slots position with no firearm in it (always true for an Open position).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "array"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "company": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "description": "Company to list; defaults to the user's company."
                  },
                  "include_disabled": {
                    "type": "integer",
                    "description": "1 to include disabled locations.",
                    "default": 0
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_core.api.storage.location_query": {
      "post": {
        "tags": [
          "ffl_core"
        ],
        "summary": "Link-field search for Storage Location: enabled locations of the user's company,",
        "description": "best match first, with a Slots position already holding a gun marked as taken.\n\n**Auth (derived from code):** Roles: Sales User / Sales Manager / Stock User / Stock Manager / System Manager\n\nSource: `apps/ffl_core/ffl_core/api/storage.py:95`",
        "operationId": "ffl_core.api.storage.location_query",
        "responses": {
          "200": {
            "description": "[(name, description)] for the dropdown."
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "doctype": {
                    "description": "Always Storage Location (set by the Link control)."
                  },
                  "txt": {
                    "description": "What the user typed."
                  },
                  "searchfield": {
                    "description": "Unused; the label and the name (barcode) are searched."
                  },
                  "start": {
                    "description": "Offset into the result."
                  },
                  "page_len": {
                    "description": "Page size."
                  },
                  "filters": {
                    "description": "Optional {company, only_free, kind}."
                  }
                },
                "required": [
                  "doctype",
                  "txt",
                  "searchfield",
                  "start",
                  "page_len",
                  "filters"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_core.api.storage.plan_slots": {
      "post": {
        "tags": [
          "ffl_core"
        ],
        "summary": "Which slots each pending receive row will fill, in one call, so a receipt of many",
        "description": "guns never offers the same slot twice.\n\n**Auth (derived from code):** Roles: Sales User / Sales Manager / Stock User / Stock Manager / System Manager\n\nSource: `apps/ffl_core/ffl_core/api/storage.py:137`",
        "operationId": "ffl_core.api.storage.plan_slots",
        "responses": {
          "200": {
            "description": "{key: [location names]}; an empty list for an Open location or a taken start slot.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "rows": {
                    "description": "Rows in receipt order (list or JSON): {key, count, start?} fills ``start`` and the next free slots in its zone; {key, count, after?} takes the first free slots after ``after`` (the suggestion for the next row). Open locations take none."
                  }
                },
                "required": [
                  "rows"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_core.api.storage.remove_positions": {
      "post": {
        "tags": [
          "ffl_core"
        ],
        "summary": "Delete the last slots of a Slots zone (A30, A29, ...). They must be empty, and the",
        "description": "zone keeps at least one -- delete the zone to remove them all.\n\n**Auth (derived from code):** Roles: Stock Manager / System Manager\n\nSource: `apps/ffl_core/ffl_core/api/storage.py:508`",
        "operationId": "ffl_core.api.storage.remove_positions",
        "responses": {
          "200": {
            "description": "{zone, positions, removed}.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "zone": {
                    "type": "string",
                    "description": "The Storage Zone name."
                  },
                  "count": {
                    "type": "integer",
                    "description": "How many to delete from the end."
                  }
                },
                "required": [
                  "zone",
                  "count"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_core.api.storage.save_floor_plan": {
      "post": {
        "tags": [
          "ffl_core"
        ],
        "summary": "Save a floor plan drawn on the Storage Locations page: its name, size and every",
        "description": "shape on it. Refused if someone else saved the plan after ``modified``.\n\n**Auth (derived from code):** Roles: Stock Manager / System Manager\n\nSource: `apps/ffl_core/ffl_core/api/storage.py:579`",
        "operationId": "ffl_core.api.storage.save_floor_plan",
        "responses": {
          "200": {
            "description": "{plan, modified, shapes, dropped}. ``dropped`` lists zones left out because they were deleted meanwhile.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "plan": {
                    "type": "string",
                    "description": "The Storage Floor Plan name."
                  },
                  "plan_name": {
                    "type": "string",
                    "description": "Name shown on the plan's tab."
                  },
                  "width": {
                    "type": "number",
                    "description": "Width of the room in feet."
                  },
                  "height": {
                    "type": "number",
                    "description": "Depth of the room in feet."
                  },
                  "shapes": {
                    "description": "List of {type: zone|wall|door|area|label, zone?, text?, x, y, w, h, r, rows?}: centre x/y and size w/h in feet, rotation r in degrees, rows = lines of slots across a Slots zone's short side. A zone may sit on one plan only; text has no < or >."
                  },
                  "modified": {
                    "type": "string",
                    "description": "The plan's ``modified`` when the editor loaded it."
                  },
                  "company": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "description": "The plan's company; defaults to the user's company."
                  }
                },
                "required": [
                  "plan",
                  "plan_name",
                  "width",
                  "height",
                  "shapes",
                  "modified"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_core.api.storage.scan_move": {
      "post": {
        "tags": [
          "ffl_core"
        ],
        "summary": "Put what was scanned into a location: a firearm by serial number, or units of",
        "description": "a non-serialized item by barcode. Nothing here touches stock or the books.\n\nA quantity comes from ``from_location`` if given, else from the units that are in\nno location, else from the one other location that holds it. When it could come\nfrom several, nothing moves and ``options`` lists them so the page can ask.\n\n**Auth (derived from code):** Roles: Sales User / Sales Manager / Stock User / Stock Manager / System Manager\n\nSource: `apps/ffl_core/ffl_core/api/storage.py:292`",
        "operationId": "ffl_core.api.storage.scan_move",
        "responses": {
          "200": {
            "description": "{result: serial | item | already | choose | error, message, serial, item_code, item_name, qty, to_location, from_location, move (the log row, for Undo), options: [{location, label, qty}] (for choose)}. error means nothing moved; the message says why and what to do.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "to_location": {
                    "type": "string",
                    "description": "Where it goes (a Storage Location name)."
                  },
                  "code": {
                    "type": "string",
                    "description": "A serial number, UPC, or item code."
                  },
                  "qty": {
                    "type": "number",
                    "description": "Units for a non-serialized item (a scan adds 1).",
                    "default": 1
                  },
                  "from_location": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "description": "Where the units are taken from, when they are in a location."
                  }
                },
                "required": [
                  "to_location",
                  "code"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_core.api.storage.set_disabled": {
      "post": {
        "tags": [
          "ffl_core"
        ],
        "summary": "Disable (or re-enable) a zone with all its positions, or one position. A",
        "description": "disabled place takes nothing new. Disabling needs it to be empty.\n\n**Auth (derived from code):** Roles: Stock Manager / System Manager\n\nSource: `apps/ffl_core/ffl_core/api/storage.py:540`",
        "operationId": "ffl_core.api.storage.set_disabled",
        "responses": {
          "200": {
            "description": "{disabled, locations}.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "disabled": {
                    "type": "integer",
                    "description": "1 to disable, 0 to enable."
                  },
                  "zone": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "description": "The Storage Zone name (give this or location)."
                  },
                  "location": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "description": "One Storage Location name."
                  }
                },
                "required": [
                  "disabled"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_core.api.storage.set_zone_layout": {
      "post": {
        "tags": [
          "ffl_core"
        ],
        "summary": "Change how a Slots zone is drawn on the floor plan. Nothing moves: every slot keeps",
        "description": "its name and what is in it.\n\n**Auth (derived from code):** Roles: Stock Manager / System Manager\n\nSource: `apps/ffl_core/ffl_core/api/storage.py:473`",
        "operationId": "ffl_core.api.storage.set_zone_layout",
        "responses": {
          "200": {
            "description": "{zone, sides, numbering}.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "zone": {
                    "type": "string",
                    "description": "The Storage Zone name."
                  },
                  "sides": {
                    "type": "integer",
                    "description": "How many sides (lines of slots) it has on the map, 1-50; a two-sided rack is 2. 0 (default) fits them to the shape it is drawn as.",
                    "default": 0
                  },
                  "numbering": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "description": "\"Odd / even\" (default: 1, 3, 5 ... down one side, 2, 4, 6 ... facing them) or \"In order\"; only two sides are counted odd / even."
                  }
                },
                "required": [
                  "zone"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_core.api.storage.stock_locations": {
      "post": {
        "tags": [
          "ffl_core"
        ],
        "summary": "For the pickers on the counter: where each non-serialized item is, so a sale",
        "description": "line can say which location it came from.\n\n**Auth (derived from code):** Roles: Sales User / Sales Manager / Stock User / Stock Manager / System Manager\n\nSource: `apps/ffl_core/ffl_core/api/storage.py:238`",
        "operationId": "ffl_core.api.storage.stock_locations",
        "responses": {
          "200": {
            "description": "{item_code: {locations: [{location, label, zone, qty}], unassigned, total, sole}}. ``unassigned`` is the stock that is in no location; ``sole`` is the one location it can only have come from (exactly one holds it and none is unassigned), else null.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "item_codes": {
                    "description": "Item codes (list or JSON list)."
                  },
                  "company": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "description": "Company; defaults to the user's company."
                  }
                },
                "required": [
                  "item_codes"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_core.api.storage.undo_move": {
      "post": {
        "tags": [
          "ffl_core"
        ],
        "summary": "Take back a move made on the page: the firearm or units go back where they were.",
        "description": "Only a hand move can be undone, only once, and only while the things are still\nwhere that move left them.\n\n**Auth (derived from code):** Roles: Sales User / Sales Manager / Stock User / Stock Manager / System Manager\n\nSource: `apps/ffl_core/ffl_core/api/storage.py:371`",
        "operationId": "ffl_core.api.storage.undo_move",
        "responses": {
          "200": {
            "description": "{ok: True, message} or {ok: False, message} when it can no longer be undone.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "move": {
                    "type": "string",
                    "description": "The Storage Move name returned by scan_move."
                  }
                },
                "required": [
                  "move"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_core.api.store_overview.get_overview": {
      "post": {
        "tags": [
          "ffl_core"
        ],
        "summary": "Everything the Gun Shop Overview page shows, one block per key.",
        "description": "A block this user may not see is null (the page leaves it out); a block that failed is\n``{\"error\": text}`` and an Error Log, and the others still load. Counts and report rows are\nshared by every user for up to a minute.\n\n**Auth (derived from code):** Roles: System Manager / Sales User / Sales Manager / Stock User / Stock Manager / Accounts User\n\nSource: `apps/ffl_core/ffl_core/api/store_overview.py:431`",
        "operationId": "ffl_core.api.store_overview.get_overview",
        "responses": {
          "200": {
            "description": "{today, now, sales: {days: [{date, net_sales, transactions, ticket_net}] (8 days, oldest first, today last; transactions and ticket_net leave returns out), report}, open_4473: {rows: [{invoice, customer_name, guns: [{serial, item_name}], nics_status, form_4473_status, started}], records, can_open}, pickups: {total, rows: [{customer, item_name, serial, source_name, days_in_store}]}, stock: {total, consignment, transfers}, drawer: {opening, expected, cash_in, cash_out, open_shifts, counted}, ad: {off} or {off, acquired, disposed, retrying, needs_person, synced_at, can_review, records?: [{doctype, name, error, terminal}]}, arriving: {total, orders: [{name, distributor, status, outstanding, received, expected}]}, records (only with with_records): [{title, items: [{label, link_type, link_to, is_query_report?, ref_doctype?}]}], links: {pos, new_order, receive, add_customer, cash_drawer, pickups}}.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "with_records": {
                    "description": "0 leaves out All records (the page asks for it once, not on every refresh).",
                    "default": 1
                  },
                  "fresh_ad": {
                    "description": "1 recounts the A&D block now instead of reading the minute-old shared count (the block's refresh button).",
                    "default": 0
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_core.api.trade_in.create_accessory_item": {
      "post": {
        "tags": [
          "ffl_core"
        ],
        "summary": "Make a new accessory / ammo / parts Item from the Trade-in dialog, for something the store has never stocked.",
        "description": "**Auth (derived from code):** Roles: Sales User / Stock Manager / System Manager\n\n**Permissions:** roles.TRADE_IN_ROLES, like the trade-in itself: the counter takes in what the seller brings. Only a non-serialized, non-firearm stock Item can be made here; any other Item stays a stock job (receive_goods.create_item).\n\nSource: `apps/ffl_core/ffl_core/api/trade_in.py:375`",
        "operationId": "ffl_core.api.trade_in.create_accessory_item",
        "responses": {
          "200": {
            "description": "{item_code, item_name}.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "item_name": {
                    "type": "string",
                    "description": "The new Item's name; also its code."
                  },
                  "item_group": {
                    "type": "string",
                    "description": "A leaf group under Ammunition, Accessory or Parts — never a firearm group."
                  },
                  "sell_price": {
                    "type": [
                      "number",
                      "null"
                    ],
                    "description": "Optional selling price (Item.standard_rate)."
                  }
                },
                "required": [
                  "item_name",
                  "item_group"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_core.api.trade_in.create_trade_in_intake": {
      "post": {
        "tags": [
          "ffl_core"
        ],
        "summary": "Create a Used Firearm Item + FFL Acquisition for an individual trade-in.",
        "description": "With payload.apply_credit truthy, the acquisition is parked as a DRAFT\n(booked at checkout submit) and the result carries `credit` — a locked\nnegative TRADE-IN-CREDIT line payload for the POS cart. Re-running the\ndialog for a serial that already has a pending draft refreshes that\ndraft (new cost honoured) instead of duplicating it.\n\nWithout apply_credit the store buys the gun and pays the seller now:\npayload.payout_method (Cash / Zelle / Check / ACH, and payout_reference\nunless Cash) is required. The gun is received on a Purchase Receipt from\nthe seller, dated today, and the payment booked with it (Dr Stock Received\nBut Not Billed / Cr Cash or the bank) so the cash drawer count includes it\n(_buy_now).\n\nAn antique (payload.is_antique, a pre-1899 receiver) never enters the bound book: it is filed under an antique\nItem (a new one for this gun, or a chosen antique Item), with credit parked as a draft Material Receipt its credit\nline locks to (_park_antique), paid now as an antique line on the seller's receipt.\n\nAccessories / ammo (payload.accessories, [{item_code, qty, rate}] with\nrate the per-unit value) come in alone (has_firearm 0) or with the gun:\nwith apply_credit a draft Material Receipt and a credit line of their own\n(_park_accessories), without it lines on the same paid receipt.\n\n**Auth (derived from code):** Roles: Sales User / Stock Manager / System Manager\n\n**Permissions:** roles.TRADE_IN_ROLES: the counter's sales role plus the stock roles; holding only the sales manager role is refused. Gated at entry, covering BOTH branches — the refresh branch (_refresh_pending_draft) rewrites A&D draft seller identity/cost and historically ran ungated (endpoint-gates hardening, 2026-08-07). A caller without a stock role files the gun under no Item (one is made for this gun) or an existing per-gun priced firearm Item (_check_counter_item); making or choosing any other Item stays a stock job. Everything behind the gate runs gate-free (firearm_intake.create_intake, receive_goods._create_receive), each of our writes with ignore_permissions; the ERPNext-internal checks against the session user (the gun's stock bundle) rest on the DocPerm setup/pos_compat.ROLE_GRANTS gives the counter.\n\nSource: `apps/ffl_core/ffl_core/api/trade_in.py:117`",
        "operationId": "ffl_core.api.trade_in.create_trade_in_intake",
        "responses": {
          "200": {
            "description": "{ok, item_code, acquisition} (None without a gun): with apply_credit from firearm_intake.create_intake (or _refresh_pending_draft), plus `credits` (one locked line per trade-in record: the gun's carries `acquisition`, the accessories' `stock_entry`), `credit` (the gun's) and `accessory_receipt`; without it from _buy_now (receive_goods._create_receive), plus `purchase_receipt` and `payout` ({entry, journal_entry}).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "payload": {
                    "description": "Trade-in intake fields (same shape as firearm_intake.create_intake plus seller identity, apply_credit, has_firearm and accessories) — dict or JSON string. ``crm_deal`` (a sell-request CRM Deal the dialog was opened from) links the trade-in to that deal once it commits and wins the deal when the gun is booked (crm.sell_requests.after_intake); it changes nothing here."
                  }
                },
                "required": [
                  "payload"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_core.api.trade_in.seller_defaults": {
      "post": {
        "tags": [
          "ffl_core"
        ],
        "summary": "Prefill for the POS Trade-in dialog's seller section.",
        "description": "A best-effort structured-name split of the Customer (generational\nsuffix pulled out even mid-name — 'pat lee IV Sampleton' →\nfirst pat, middle lee, last Sampleton, suffix IV) plus their\nprimary address as a single line ('addr1, City ST zip' — the shape the\nFastBound push parses). Everything is editable in the dialog; this only\nsaves retyping.\n\n**Auth (derived from code):** Roles: Sales User / Sales Manager / Stock Manager / System Manager\n\nSource: `apps/ffl_core/ffl_core/api/trade_in.py:619`",
        "operationId": "ffl_core.api.trade_in.seller_defaults",
        "responses": {
          "200": {
            "description": "{source_first_name, source_middle_name, source_last_name, source_suffix, source_address_line1, ...} or {} when unknown.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "customer": {
                    "type": "string",
                    "description": "Customer name; unknown/blank returns {}."
                  }
                },
                "required": [
                  "customer"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_core.assignment_notice.acknowledge": {
      "post": {
        "tags": [
          "ffl_core"
        ],
        "summary": "Say you saw these assignments. Each one is yours or the call is refused; one that is closed,",
        "description": "cancelled, gone or never asked is skipped. The first time, the time is stored on the ToDo and\nthe document gets a timeline comment; after that it only dismisses today's reminder.\n\n**Auth (derived from code):** Any authenticated user — no explicit role gate at function entry (deliberate open reads document this in Permissions).\n\nSource: `apps/ffl_core/ffl_core/assignment_notice.py:206`",
        "operationId": "ffl_core.assignment_notice.acknowledge",
        "responses": {
          "200": {
            "description": "What is still waiting, as :func:`pending` returns it.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "array"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "names": {
                    "type": "array",
                    "description": "ToDo names (a list, or its JSON), at most 50."
                  }
                },
                "required": [
                  "names"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_core.assignment_notice.done": {
      "post": {
        "tags": [
          "ffl_core"
        ],
        "summary": "Close one of your tasks. Only the person it is assigned to can; one already closed or",
        "description": "cancelled is left as it is. Closing goes through Frappe's own assignment close, so the\nassignment comes off the document, and the document gets a timeline comment.\n\n**Auth (derived from code):** Any authenticated user — no explicit role gate at function entry (deliberate open reads document this in Permissions).\n\nSource: `apps/ffl_core/ffl_core/assignment_notice.py:276`",
        "operationId": "ffl_core.assignment_notice.done",
        "responses": {
          "200": {
            "description": "{\"closed\": False when it was already closed or cancelled, \"open\": how many open tasks you have left}.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "name": {
                    "type": "string",
                    "description": "ToDo name."
                  }
                },
                "required": [
                  "name"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_core.assignment_notice.my_tasks": {
      "post": {
        "tags": [
          "ffl_core"
        ],
        "summary": "Your open tasks: every Open ToDo assigned to you, including system alerts that never pop",
        "description": "up; oldest first (at most 200).\n\n**Auth (derived from code):** Any authenticated user — no explicit role gate at function entry (deliberate open reads document this in Permissions).\n\nSource: `apps/ffl_core/ffl_core/assignment_notice.py:244`",
        "operationId": "ffl_core.assignment_notice.my_tasks",
        "responses": {
          "200": {
            "description": "[{\"name\": ToDo, \"assigned_by\": full name, \"reference_type\", \"reference_name\", \"title\" (all three None when the document is gone or there is none), \"url\": where a CRM lead or deal opens in CRM (None for anything else, which opens as a desk form), \"description\": plain text, \"priority\", \"date\": due date or None, \"creation\", \"seen_on\": when you said you saw it or None, \"asks\": whether it asked you to say you saw it}].",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "array"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        }
      }
    },
    "/api/method/ffl_core.assignment_notice.pending": {
      "post": {
        "tags": [
          "ffl_core"
        ],
        "summary": "Your assignments waiting for you to say you saw them, and the ones you saw but have not",
        "description": "closed that are due today's reminder; oldest first (at most 50).\n\n**Auth (derived from code):** Any authenticated user — no explicit role gate at function entry (deliberate open reads document this in Permissions).\n\nSource: `apps/ffl_core/ffl_core/assignment_notice.py:191`",
        "operationId": "ffl_core.assignment_notice.pending",
        "responses": {
          "200": {
            "description": "[{\"name\": ToDo, \"assigned_by\": full name, \"reference_type\", \"reference_name\", \"title\" (all three None when the document is gone or there is none), \"url\": where a CRM lead or deal opens in CRM (None for anything else, which opens as a desk form), \"description\": plain text, \"priority\", \"date\": due date or None, \"creation\", \"seen_on\": when you said you saw it or None, \"reminder\": True for one you already saw}].",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "array"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        }
      }
    },
    "/api/method/ffl_core.assignment_notice.task_count": {
      "post": {
        "tags": [
          "ffl_core"
        ],
        "summary": "How many open tasks you have (the number next to My tasks).",
        "description": "**Auth (derived from code):** Any authenticated user — no explicit role gate at function entry (deliberate open reads document this in Permissions).\n\nSource: `apps/ffl_core/ffl_core/assignment_notice.py:266`",
        "operationId": "ffl_core.assignment_notice.task_count",
        "responses": {
          "200": {
            "description": "The count of Open ToDos assigned to you.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "integer"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        }
      }
    },
    "/api/method/ffl_core.customer_flags.apply_id_scan": {
      "post": {
        "tags": [
          "ffl_core"
        ],
        "summary": "Bring an existing customer's ID documents and address up to the ID just scanned.",
        "description": "For a customer who renewed or replaced an ID, or moved. Nothing is written while FFL\nSettings → Store Customer ID Numbers is off, for a customer who is not an Individual, or\nwhen the ID is someone else's (unless ``force``): another first + last name, or another\ndate of birth than the one on file (a parent and child can share a name).\n\n* ID documents: the Driver License row from ``idNumber`` / ``expiry`` and the CCW row from\n  ``carryNumber`` / ``carryExpiry``. A row of that type is updated in place (the one with\n  the same number, else the only one); otherwise a row is added. An expiry the scan does\n  not carry leaves the stored one alone, unless the number changed.\n* Date of birth and gender: filled when empty, never overwritten.\n* Address: when the ID's street and ZIP are not the primary address (an ID whose ZIP did\n  not read changes nothing). An address the customer already has under that street and\n  ZIP becomes the primary one. Otherwise the primary address is changed in place when\n  only this customer uses it; a shared one is left alone and a new primary address is\n  made. The old address goes on the customer's timeline.\n\n**Auth (derived from code):** Requires write permission on Customer (Frappe DocType permission check).\n\nSource: `apps/ffl_core/ffl_core/customer_flags.py:276`",
        "operationId": "ffl_core.customer_flags.apply_id_scan",
        "responses": {
          "200": {
            "description": "{\"changed\": [str]} naming what was written (\"Driver License\", \"CCW\", \"Date of Birth\", \"Gender\", \"Address\"; empty when the record already matched), or {\"changed\": [], \"mismatch\": {\"on_id\": str, \"customer\": str}} (each a name, with \"(born YYYY-MM-DD)\" when the dates of birth differ) when the ID is someone else's and nothing was written.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "customer": {
                    "type": "string",
                    "description": "Customer name (document id)."
                  },
                  "scan": {
                    "description": "What ``ffl.aamva.parse(raw, {ids: true})`` returned in the browser: first, last, address1, address2, city, state, zip, country, idNumber, dob, expiry, gender and, for a licence to carry, carryNumber, carryExpiry."
                  },
                  "force": {
                    "description": "Write although the name or date of birth on the ID differs from the customer's.",
                    "default": false
                  }
                },
                "required": [
                  "customer",
                  "scan"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_core.customer_flags.banned_order_rows": {
      "post": {
        "tags": [
          "ffl_core"
        ],
        "summary": "Which Pending Order rows belong to a Banned customer, for the page's red badge.",
        "description": "A web or GunBroker order is booked to a customer only once it has shipped, so\nits buyer is looked up the way that booking will: a Woo order by its billing\nemail (customer email, then merged-email alias); a GunBroker order by its linked\ncustomer, then the buyer's GunBroker id (field, then alias), then email.\n\n**Auth (derived from code):** Requires read permission on Customer (Frappe DocType permission check).\n\nSource: `apps/ffl_core/ffl_core/customer_flags.py:556`",
        "operationId": "ffl_core.customer_flags.banned_order_rows",
        "responses": {
          "200": {
            "description": "{\"woo\": [names], \"gb\": [names], \"customers\": [names]} — only the Banned ones.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "woo_orders": {
                    "description": "Woo Online Order names on the page."
                  },
                  "gb_orders": {
                    "description": "GunBroker Order names on the page."
                  },
                  "customers": {
                    "description": "Customer names of the counter rows."
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_core.customer_flags.find_customers_by_id_number": {
      "post": {
        "tags": [
          "ffl_core"
        ],
        "summary": "Customers holding this ID number (a licence scanned at the register).",
        "description": "Only while FFL Settings → Store Customer ID Numbers is on (otherwise none are\nstored, and the answer is an empty list). Compared without case, spaces or dashes.\n\n**Auth (derived from code):** Requires read permission on Customer (Frappe DocType permission check).\n\nSource: `apps/ffl_core/ffl_core/customer_flags.py:245`",
        "operationId": "ffl_core.customer_flags.find_customers_by_id_number",
        "responses": {
          "200": {
            "description": "[{\"name\", \"customer_name\", \"customer_status\"}], at most 5.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "array"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "id_number": {
                    "type": "string",
                    "description": "The number read from the ID."
                  }
                },
                "required": [
                  "id_number"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_core.customer_flags.find_customers_by_scan": {
      "post": {
        "tags": [
          "ffl_core"
        ],
        "summary": "Customers a scanned licence may belong to (the gunsmith work order's Scan ID): by",
        "description": "its number (only while ID numbers are stored, as :func:`find_customers_by_id_number`),\nthen by first + last name. A name match is only a guess, so the caller lets the clerk\npick; a number match is the person.\n\n**Auth (derived from code):** Requires read permission on Customer (Frappe DocType permission check).\n\nSource: `apps/ffl_core/ffl_core/customer_flags.py:445`",
        "operationId": "ffl_core.customer_flags.find_customers_by_scan",
        "responses": {
          "200": {
            "description": "[{\"name\", \"customer_name\", \"customer_status\", \"address\": primary address on one line, \"by_id\": matched on the ID number}], at most 5.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "array"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "first": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "description": "First name read from the ID."
                  },
                  "last": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "description": "Last name read from the ID."
                  },
                  "id_number": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "description": "The licence number read from the ID, if any."
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_core.customer_flags.find_possible_duplicates": {
      "post": {
        "tags": [
          "ffl_core"
        ],
        "summary": "Existing customers a new one may duplicate, for the New Customer dialog.",
        "description": "Matches the customer's email (or an email merged into it), mobile number\n(last 10 digits) and — while the store keeps ID numbers — an ID number.\n\n**Auth (derived from code):** Requires read permission on Customer (Frappe DocType permission check).\n\nSource: `apps/ffl_core/ffl_core/customer_flags.py:501`",
        "operationId": "ffl_core.customer_flags.find_possible_duplicates",
        "responses": {
          "200": {
            "description": "[{\"name\", \"customer_name\", \"customer_status\", \"matched\": [\"email\" | \"phone\" | \"id_number\"]}], at most 5.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "array"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "email": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "description": "Email typed in the dialog."
                  },
                  "phone": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "description": "Mobile number typed in the dialog."
                  },
                  "id_number": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "description": "Driver licence number from a scan (ignored when ID numbers are off)."
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_core.customer_flags.get_customer_flags": {
      "post": {
        "tags": [
          "ffl_core"
        ],
        "summary": "What the counter panel shows when this customer is picked.",
        "description": "**Auth (derived from code):** Requires read permission on Customer (Frappe DocType permission check).\n\nSource: `apps/ffl_core/ffl_core/customer_flags.py:139`",
        "operationId": "ffl_core.customer_flags.get_customer_flags",
        "responses": {
          "200": {
            "description": "{\"name\", \"customer_name\", \"status\", \"status_reason\" (only when not Active), \"banned\": Banned with no open override, \"override_until\": end of an open manager override or None, \"can_override\": whether the caller may override, \"alerts\": [{\"message\", \"created_by\", \"created_on\"}] (active ones, oldest first), \"tags\": [str], \"family\": {\"primary\": {\"name\", \"customer_name\"} or None, \"relationship\", \"members\": int}, \"ids\": [{\"id_type\", \"expiry_date\", \"expired\": bool}] for ID documents expired or expiring within 30 days, \"agreements\": [{\"template\", \"state\", \"expires_on\", \"agreement\"}] for each active Agreement Template shown on the counter panel — state is signed, expiring (within 30 days), expired, pending or missing, \"membership\": the member badge (``membership_benefits.membership_badge``: {\"text\", \"memberships\"}) or None}. Never carries an ID number or date of birth.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "customer": {
                    "type": "string",
                    "description": "Customer name (document id)."
                  }
                },
                "required": [
                  "customer"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_core.customer_flags.override_customer_ban": {
      "post": {
        "tags": [
          "ffl_core"
        ],
        "summary": "Manager lets a Banned customer be served for the next 30 minutes.",
        "description": "Opens the window every counter screen and the server-side sale gate read\n(``ban_override_until`` / ``ban_override_by``) and records who and why on the\ncustomer's timeline. The customer stays Banned.\n\n**Auth (derived from code):** Roles: Sales Manager / System Manager\n\nSource: `apps/ffl_core/ffl_core/customer_flags.py:205`",
        "operationId": "ffl_core.customer_flags.override_customer_ban",
        "responses": {
          "200": {
            "description": "{\"customer\": name, \"override_until\": the window's end, \"by\": the manager}.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "customer": {
                    "type": "string",
                    "description": "Customer name (document id); must be Banned."
                  },
                  "reason": {
                    "type": "string",
                    "description": "Why the sale is allowed (required, kept on the timeline)."
                  }
                },
                "required": [
                  "customer",
                  "reason"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_core.customer_profile.get_family": {
      "post": {
        "tags": [
          "ffl_core"
        ],
        "summary": "The family a customer belongs to, for the Customer form's Family section.",
        "description": "**Auth (derived from code):** Requires read permission on Customer (Frappe DocType permission check).\n\nSource: `apps/ffl_core/ffl_core/customer_profile.py:317`",
        "operationId": "ffl_core.customer_profile.get_family",
        "responses": {
          "200": {
            "description": "{\"primary\": {\"name\", \"customer_name\"} or None, \"relationship\": the customer's relationship to that primary or None, \"members\": [{\"name\", \"customer_name\", \"relationship\"}] — empty for a member, \"can_merge\": whether the caller may merge customers (drives the form's Merge button)}.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "customer": {
                    "type": "string",
                    "description": "Customer name (document id)."
                  }
                },
                "required": [
                  "customer"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_core.customer_profile.get_stored_id_counts": {
      "post": {
        "tags": [
          "ffl_core"
        ],
        "summary": "What turning off Store Customer ID Numbers would erase, for the FFL Settings confirm.",
        "description": "**Auth (derived from code):** Requires write permission on FFL Settings (Frappe DocType permission check).\n\nSource: `apps/ffl_core/ffl_core/customer_profile.py:135`",
        "operationId": "ffl_core.customer_profile.get_stored_id_counts",
        "responses": {
          "200": {
            "description": "{\"dates_of_birth\": int, \"id_numbers\": int, \"total\": int} across all customers.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        }
      }
    },
    "/api/method/ffl_core.customer_profile.merge_customer": {
      "post": {
        "tags": [
          "ffl_core"
        ],
        "summary": "Merge a duplicate customer into the one to keep; the duplicate is deleted.",
        "description": "The source's alerts and ID documents are copied onto the target (identical\nrows skipped), a date of birth the target lacks is filled, a Banned source\nmakes the target Banned, and the source's own family link is carried when\nthe target has none. The source's email, the emails on its Contacts, its\nGunBroker user id and its own aliases are recorded on the target as aliases\n(values the target already has are skipped), so a later Woo / GunBroker order\ncarrying one of them lands on the target instead of starting a duplicate.\nThen ERPNext's merge-rename moves every link —\ninvoices, orders, 4473s, payments, contacts, addresses, family members — to\nthe target and deletes the source; open sales documents get the target's\ndisplay name. Refused for the Woo web-store aggregate and the walk-in customer,\nwhen both are FFL dealers with different licence numbers, when only the source\nis a dealer, when either is a register's default customer, or when the merge\nwould nest one family inside another.\n\n**Auth (derived from code):** Roles: Sales Manager / System Manager\n\nSource: `apps/ffl_core/ffl_core/customer_profile.py:343`",
        "operationId": "ffl_core.customer_profile.merge_customer",
        "responses": {
          "200": {
            "description": "{\"name\": target, \"customer_name\": target's display name, \"alerts_copied\": int, \"ids_copied\": int}.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "source": {
                    "type": "string",
                    "description": "Customer to merge away (deleted)."
                  },
                  "target": {
                    "type": "string",
                    "description": "Customer to keep."
                  }
                },
                "required": [
                  "source",
                  "target"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_core.ffl_core.doctype.inventory_import.inventory_import.start": {
      "post": {
        "tags": [
          "ffl_core"
        ],
        "summary": "Preview or import the attached CSV in the background: one catalog lookup",
        "description": "per unknown UPC outlasts a web request on a new store's file. The result is\nsaved on the page (``last_run``) and announced with ``inventory_import_done``.\n\n**Auth (derived from code):** Roles: System Manager\n\nSource: `apps/ffl_core/ffl_core/ffl_core/doctype/inventory_import/inventory_import.py:54`",
        "operationId": "ffl_core.ffl_core.doctype.inventory_import.inventory_import.start",
        "responses": {
          "200": {
            "description": "{queued: True}.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "mode": {
                    "type": "string",
                    "description": "\"preview\" reads every row and writes nothing; \"import\" creates the missing items and posts the opening stock."
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_core.firearm.available_serials_for_items": {
      "post": {
        "tags": [
          "ffl_core"
        ],
        "summary": "Return {item_code: [in-stock serial, ...]} so the POS 4473 dialog can offer",
        "description": "a pick-list of real on-hand serials instead of free-typing one.\n\nEvery firearm has has_serial_no=1 and its serials live in the Serial No\ntable — Item.firearm_serial fallback was removed when the Used Firearm\npath was unified. Codes with nothing on hand map to [] so the caller can\nwarn + block the sale.\n\n**Auth (derived from code):** Roles: Sales User / Sales Manager / Stock Manager / System Manager\n\nSource: `apps/ffl_core/ffl_core/firearm.py:642`",
        "operationId": "ffl_core.firearm.available_serials_for_items",
        "responses": {
          "200": {
            "description": "{item_code: [in-stock serial, ...]}.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "item_codes": {
                    "type": "array",
                    "description": "Item codes — list or JSON string."
                  },
                  "exclude_unavailable": {
                    "description": "Default True: drop guns that are held / consigned_out / in a consignment warehouse so the picker never offers a gun that can't actually be sold. Pass False for a caller that needs the raw on-hand list (never the POS pick-list itself).",
                    "default": true
                  },
                  "current_invoice": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "description": "Optional POS Invoice docname — the serial already parked on THIS invoice's own line stays offered (incident a past invoice, see _pos_picker_excluded_serials). The POS 4473 dialog passes it so the serial on the line the cashier is completing doesn't vanish from its own dropdown. On a web order's in-store pickup ticket, the gun that order reserved stays offered too."
                  },
                  "customer": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "description": "Optional buyer — a gun held for this customer's CRM deal stays offered."
                  }
                },
                "required": [
                  "item_codes"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_core.firearm.available_serials_with_prices": {
      "post": {
        "tags": [
          "ffl_core"
        ],
        "summary": "Like available_serials_for_items but enriches each serial with sell_price",
        "description": "and purchase_rate (cost), sorted by sell_price ascending so the POS picks\nthe cheapest in-stock unit by default. Used by the POS Item Details serial\npicker to render a price-first dropdown.\n\n**Auth (derived from code):** Roles: Sales User / Sales Manager / Stock Manager / System Manager\n\nSource: `apps/ffl_core/ffl_core/firearm.py:1385`",
        "operationId": "ffl_core.firearm.available_serials_with_prices",
        "responses": {
          "200": {
            "description": "{item_code: [{\"serial\", \"sell_price\", \"purchase_rate\", \"held_for_customer\"?}, ...]}, sorted by sell_price ascending.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "item_codes": {
                    "type": "array",
                    "description": "Item codes — list or JSON string."
                  },
                  "exclude_unavailable": {
                    "description": "Default True: drop held / consigned_out / consignment-warehouse guns so the POS picker never offers an unsellable one. Callers that need the RAW list pass False — the scan-to-add / edit price lookup (_serial_ctx_for_item), the checkout-gate summary (pos_pricing_summary) and the Create Order picker (manual_order.available_serials), none of which is the POS pick-list and each of which must keep seeing every on-hand serial (e.g. a serial held only by the very invoice being edited).",
                    "default": true
                  },
                  "current_invoice": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "description": "Optional POS Invoice docname — the serial already parked on THIS invoice's own line stays offered (incident a past invoice); the Item-Details picker passes it so editing a firearm line doesn't drop its own serial from the dropdown."
                  },
                  "customer": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "description": "Optional buyer — a gun held for this customer's CRM deal stays offered, marked ``held_for_customer``."
                  }
                },
                "required": [
                  "item_codes"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_core.firearm.firearm_items_in": {
      "post": {
        "tags": [
          "ffl_core"
        ],
        "summary": "Return the subset of item_codes that are REGULATED firearms (antiques excluded).",
        "description": "Called from POS JS to decide whether to surface the 4473 button / whether\nthe submit gate applies. Antique firearms (GCA-exempt) need no 4473, so\nthey are filtered out here — an antique-only cart looks like an accessories\ncart to the POS and completes without the charge-then-hold flow.\n\n**Auth (derived from code):** Roles: Sales User / Sales Manager / Stock Manager / System Manager\n\nSource: `apps/ffl_core/ffl_core/firearm.py:425`",
        "operationId": "ffl_core.firearm.firearm_items_in",
        "responses": {
          "200": {
            "description": "The subset of item_codes that are regulated firearms.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "array"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "item_codes": {
                    "type": "array",
                    "description": "Item codes — a list or a JSON string (Frappe transports list args as JSON over the wire)."
                  }
                },
                "required": [
                  "item_codes"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_core.firearm.get_transfer_config": {
      "post": {
        "tags": [
          "ffl_core"
        ],
        "summary": "POS transfer-dialog config: the fee item + default per-firearm fee.",
        "description": "Lazily creates the TRANSFER-FEE service item on first use — by the time the POS\nis live the site's UOM/Item-Group masters exist, unlike at install/migrate time\n(a fresh install runs hooks/patches before ERPNext's setup wizard). Mirrors\nreceive_goods.get_receive_sources for reading FFL Settings.\n\n**Auth (derived from code):** Roles: Sales User / Sales Manager / Stock Manager / System Manager\n\nSource: `apps/ffl_core/ffl_core/firearm.py:1527`",
        "operationId": "ffl_core.firearm.get_transfer_config",
        "responses": {
          "200": {
            "description": "{\"fee_item\": <service Item code>, \"fee_amount\": <default fee>}.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        }
      }
    },
    "/api/method/ffl_core.firearm.in_stock_firearm_serials": {
      "post": {
        "tags": [
          "ffl_core"
        ],
        "summary": "Every in-stock firearm serial, for the POS customer-transfer picker.",
        "description": "The two cart-driven pickers (available_serials_for_items, firearm_items_in)\nneed item_codes up front; a transfer starts before any gun is in the cart,\nso this returns the whole in-stock firearm set instead. Price is informational\n(picker label) — reuses the uniform/per-serial logic of\navailable_serials_with_prices; the transfer always adds the gun at $0.\n\nCustody guns are deliberately NOT excluded here (exclude_custody=False),\nunlike in the two SALE pickers. This dialog is how a customer's gun goes\nhome: hiding custody guns from it would strand every gun the custody\nwarehouse receives, which is the opposite of the point.\n\n**Auth (derived from code):** Roles: Sales User / Sales Manager / Stock Manager / System Manager\n\nSource: `apps/ffl_core/ffl_core/firearm.py:1586`",
        "operationId": "ffl_core.firearm.in_stock_firearm_serials",
        "responses": {
          "200": {
            "description": "[{serial, item_code, item_name, sell_price}], ordered item then serial.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "array"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "exclude_unavailable": {
                    "description": "Default True: drop held / consigned_out / consignment-warehouse guns — a transfer must not offer a gun already spoken for or gone to a dealer. Pass False for the raw in-stock set.",
                    "default": true
                  },
                  "customer": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "description": "Optional transferee — a gun held for this customer's CRM deal stays offered."
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_core.firearm.pos_pricing_summary": {
      "post": {
        "tags": [
          "ffl_core"
        ],
        "summary": "Per-item POS pricing summary — the single data source for the POS card",
        "description": "price range, the add-to-cart rate seed, the picker's auto-pick decision and\nthe checkout gate.\n\n**Auth (derived from code):** Roles: Sales User / Sales Manager / Stock Manager / System Manager\n\nSource: `apps/ffl_core/ffl_core/firearm.py:1479`",
        "operationId": "ffl_core.firearm.pos_pricing_summary",
        "responses": {
          "200": {
            "description": "{code: {\"is_firearm\": bool, \"uniform\": 0|1, \"n\": <active serials>, \"min\": float|None, \"max\": float|None}}. min/max range over the normalised per-serial prices (uniform mode → standard_rate; 0 → None un-priced, excluded from min/max). Non-firearm / unknown codes come back with n=0 so the frontend can cache the negative.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "item_codes": {
                    "type": "array",
                    "description": "Item codes — list or JSON string."
                  }
                },
                "required": [
                  "item_codes"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_core.firearm.toggle_serial_service_need": {
      "post": {
        "tags": [
          "ffl_core"
        ],
        "summary": "Flip Serial No.needs_service AND keep the gunsmith ToDo queue in sync.",
        "description": "Used by the Service Needed pill on the Item form's Serial Numbers tab.\nGoes through this single helper (instead of raw db.set_value on the client)\nso the ToDo create/close stays glued to the flag — toggling on creates a\nToDo, toggling off closes the matching Open ones.\n\nPermission gate: the helpers below elevate via flags.ignore_permissions /\nraw db.set_value to bypass ToDo/Serial No DocPerms (managers vs cashiers).\nWithout this gate, any logged-in user could flip needs_service on any\nserial — including silently closing a gunsmith's Open ToDo queue. Restrict\nto roles that already own Serial No writes.\n\n**Auth (derived from code):** Requires write permission on Serial No (Frappe DocType permission check).\n\n**Permissions:** Frappe write permission on Serial No (a DocType permission check, not a fixed role list — whichever roles carry Serial No write).\n\nSource: `apps/ffl_core/ffl_core/firearm.py:739`",
        "operationId": "ffl_core.firearm.toggle_serial_service_need",
        "responses": {
          "200": {
            "description": "{\"ok\": True, \"needs_service\": 0|1}.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "serial": {
                    "type": "string",
                    "description": "Serial No name."
                  },
                  "value": {
                    "description": "Truthy to flag needs_service (creates a gunsmith ToDo); falsy to clear it (closes matching Open ToDos)."
                  }
                },
                "required": [
                  "serial",
                  "value"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_core.gunsmith.cancel_work_order": {
      "post": {
        "tags": [
          "ffl_core"
        ],
        "summary": "Close a job that will not be done. A gun in the bound book still goes back through",
        "description": "pick-up (its disposition), so a logged job is not cancelled: clear its charges and\npick it up instead. A deposit held is refunded afterwards (:func:`refund_deposit`).\n\n**Auth (derived from code):** Roles: Sales User / Sales Manager / Stock Manager / System Manager\n\nSource: `apps/ffl_core/ffl_core/gunsmith.py:471`",
        "operationId": "ffl_core.gunsmith.cancel_work_order",
        "responses": {
          "200": {
            "description": "{\"status\", \"deposit_held\"}.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "name": {
                    "type": "string",
                    "description": "Gunsmith Work Order name; not Picked Up or Cancelled."
                  },
                  "reason": {
                    "type": "string",
                    "description": "Why."
                  }
                },
                "required": [
                  "name",
                  "reason"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_core.gunsmith.charge_details": {
      "post": {
        "tags": [
          "ffl_core"
        ],
        "summary": "A part picked or scanned onto a job's charges: its name and its list price for the",
        "description": "customer, as Create Order prices a line (``price_approval.list_rate``). The counter\ncan't read Item Price itself.\n\n**Auth (derived from code):** Roles: Sales User / Sales Manager / Stock Manager / System Manager\n\nSource: `apps/ffl_core/ffl_core/gunsmith.py:302`",
        "operationId": "ffl_core.gunsmith.charge_details",
        "responses": {
          "200": {
            "description": "{\"item_name\", \"rate\": the list price, 0 when there is none}.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "item_code": {
                    "type": "string",
                    "description": "The Item charged."
                  },
                  "customer": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "description": "The job's customer, whose price list applies; else the default selling list."
                  }
                },
                "required": [
                  "item_code"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_core.gunsmith.complete_work": {
      "post": {
        "tags": [
          "ffl_core"
        ],
        "summary": "The register's Complete: the clerk confirms what was done and what it costs; the",
        "description": "job keeps them, is Ready, and is handed back as :func:`open_pickup` does — at once\nwith nothing to bill and nothing held, else through the draft pick-up invoice the\nregister loads into its cart.\n\n**Auth (derived from code):** Roles: Sales User / Sales Manager / Stock Manager / System Manager\n\nSource: `apps/ffl_core/ffl_core/gunsmith.py:330`",
        "operationId": "ffl_core.gunsmith.complete_work",
        "responses": {
          "200": {
            "description": "As :func:`open_pickup`: {\"pos_invoice\", \"already\": False} or {\"picked_up\": True, \"refund_due\"}.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "name": {
                    "type": "string",
                    "description": "Gunsmith Work Order name; Received, In Progress or Ready, with no pick-up invoice open."
                  },
                  "work_performed": {
                    "type": "string",
                    "description": "What was done."
                  },
                  "lines": {
                    "description": "JSON list of the charges, [{\"item_code\", \"description\", \"qty\", \"rate\"}]; they replace the job's."
                  }
                },
                "required": [
                  "name",
                  "work_performed"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_core.gunsmith.create_work_order": {
      "post": {
        "tags": [
          "ffl_core"
        ],
        "summary": "Take a gun in at the register (its Work Order button): the job, logged in the",
        "description": "bound book now when asked, and the payment line for what the customer pays now.\n\n**Auth (derived from code):** Roles: Sales User / Sales Manager / Stock Manager / System Manager\n\nSource: `apps/ffl_core/ffl_core/gunsmith.py:143`",
        "operationId": "ffl_core.gunsmith.create_work_order",
        "responses": {
          "200": {
            "description": "{\"name\", \"customer\", \"customer_name\", \"status\", \"purchase_receipt\", \"authorization_template\": the intake authorization the register asks the customer to sign next, or None, \"deposit_line\": the locked GUNSMITH-DEPOSIT row for pay_now (as :func:`deposit_line`), or None}.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "payload": {
                    "description": "JSON object of the job's intake fields — customer, manufacturer, model, serial_number and work_requested required; caliber, firearm_type, accessories, condition, estimated_cost, estimated_completion; log_in_bound_book with id_type and id_number to log the gun now; pay_now, an amount paid towards the job now."
                  }
                },
                "required": [
                  "payload"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_core.gunsmith.deposit_line": {
      "post": {
        "tags": [
          "ffl_core"
        ],
        "summary": "A payment towards an open job (Recent Orders › Take payment): the locked",
        "description": "GUNSMITH-DEPOSIT row for the register's cart. Booked when that sale is paid.\n\n**Auth (derived from code):** Roles: Sales User / Sales Manager / Stock Manager / System Manager\n\nSource: `apps/ffl_core/ffl_core/gunsmith.py:175`",
        "operationId": "ffl_core.gunsmith.deposit_line",
        "responses": {
          "200": {
            "description": "{\"customer\", \"deposit_line\": {\"item_code\", \"qty\", \"rate\", \"ffl_locked_rate\", \"income_account\", \"ffl_work_order\", \"description\", …}}.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "name": {
                    "type": "string",
                    "description": "Gunsmith Work Order name; Received, In Progress or Ready."
                  },
                  "amount": {
                    "type": "number",
                    "description": "What the customer pays now, above 0."
                  }
                },
                "required": [
                  "name",
                  "amount"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_core.gunsmith.get_state": {
      "post": {
        "tags": [
          "ffl_core"
        ],
        "summary": "What the work order form shows and offers.",
        "description": "**Auth (derived from code):** Roles: Sales User / Sales Manager / Stock Manager / System Manager\n\nSource: `apps/ffl_core/ffl_core/gunsmith.py:108`",
        "operationId": "ffl_core.gunsmith.get_state",
        "responses": {
          "200": {
            "description": "{\"labor_item\", \"deposit_held\", \"charges\", \"authorization\": {\"template\", \"state\", \"agreement\"} or None, \"drafts\": {\"deposit\", \"pickup\", \"refund\"}}.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "name": {
                    "type": "string",
                    "description": "Gunsmith Work Order name."
                  }
                },
                "required": [
                  "name"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_core.gunsmith.labor_item": {
      "post": {
        "tags": [
          "ffl_core"
        ],
        "summary": "The labor item a new job's first charge line uses (FFL Settings › Gunsmithing,",
        "description": "which the counter can't read itself).\n\n**Auth (derived from code):** Roles: Sales User / Sales Manager / Stock Manager / System Manager\n\nSource: `apps/ffl_core/ffl_core/gunsmith.py:290`",
        "operationId": "ffl_core.gunsmith.labor_item",
        "responses": {
          "200": {
            "description": "The Item name.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        }
      }
    },
    "/api/method/ffl_core.gunsmith.log_in_bound_book": {
      "post": {
        "tags": [
          "ffl_core"
        ],
        "summary": "Log a job's gun in the bound book now (a job created unlogged, or one whose",
        "description": "first attempt failed).\n\n**Auth (derived from code):** Roles: Sales User / Sales Manager / Stock Manager / System Manager\n\nSource: `apps/ffl_core/ffl_core/gunsmith.py:506`",
        "operationId": "ffl_core.gunsmith.log_in_bound_book",
        "responses": {
          "200": {
            "description": "{\"purchase_receipt\", \"serial_no\", \"item_code\"}.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "name": {
                    "type": "string",
                    "description": "Gunsmith Work Order name; not Picked Up or Cancelled."
                  },
                  "id_type": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "description": "The customer's ID type, when not on the job yet."
                  },
                  "id_number": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "description": "The customer's ID number, when not on the job yet."
                  }
                },
                "required": [
                  "name"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_core.gunsmith.mark_ready": {
      "post": {
        "tags": [
          "ffl_core"
        ],
        "summary": "Received / In Progress → Ready: the work is done and recorded.",
        "description": "**Auth (derived from code):** Roles: Sales User / Sales Manager / Stock Manager / System Manager\n\nSource: `apps/ffl_core/ffl_core/gunsmith.py:408`",
        "operationId": "ffl_core.gunsmith.mark_ready",
        "responses": {
          "200": {
            "description": "{\"status\", \"completed_on\"}.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "name": {
                    "type": "string",
                    "description": "Gunsmith Work Order name; needs Work Performed."
                  }
                },
                "required": [
                  "name"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_core.gunsmith.notify_customer": {
      "post": {
        "tags": [
          "ffl_core"
        ],
        "summary": "Tell the customer the gun is ready, and record who told them, how and when.",
        "description": "Email sends the store's \"Gunsmith Work Ready\" email now (the customer needs an\nemail address). Phone and Text are made by staff; this records them.\n\n**Auth (derived from code):** Roles: Sales User / Sales Manager / Stock Manager / System Manager\n\nSource: `apps/ffl_core/ffl_core/gunsmith.py:430`",
        "operationId": "ffl_core.gunsmith.notify_customer",
        "responses": {
          "200": {
            "description": "{\"notified_via\", \"notified_on\", \"email\": address the email went to, or None}.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "name": {
                    "type": "string",
                    "description": "Gunsmith Work Order name; must be Ready."
                  },
                  "via": {
                    "type": "string",
                    "description": "Phone, Email or Text."
                  }
                },
                "required": [
                  "name",
                  "via"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_core.gunsmith.open_deposit": {
      "post": {
        "tags": [
          "ffl_core"
        ],
        "summary": "A payment towards an open job parked as its own draft register invoice — what an",
        "description": "agent opens instead of the register cart's :func:`deposit_line`. One open deposit\ndraft per job: a second call returns the one already open, at its own amount.\n\n**Auth (derived from code):** Roles: Sales User / Sales Manager / Stock Manager / System Manager\n\nSource: `apps/ffl_core/ffl_core/gunsmith.py:199`",
        "operationId": "ffl_core.gunsmith.open_deposit",
        "responses": {
          "200": {
            "description": "{\"pos_invoice\", \"already\": bool, \"amount\": the draft's deposit amount}.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "name": {
                    "type": "string",
                    "description": "Gunsmith Work Order name; Received, In Progress or Ready."
                  },
                  "amount": {
                    "type": "number",
                    "description": "What the customer pays now, above 0."
                  }
                },
                "required": [
                  "name",
                  "amount"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_core.gunsmith.open_pickup": {
      "post": {
        "tags": [
          "ffl_core"
        ],
        "summary": "Hand the gun back. With nothing to charge and no deposit held, the job is",
        "description": "picked up now; otherwise this opens (or returns) the draft register invoice with\nthe charges and the deposit held coming off them, and its submit picks the job up.\n\n**Auth (derived from code):** Roles: Sales User / Sales Manager / Stock Manager / System Manager\n\nSource: `apps/ffl_core/ffl_core/gunsmith.py:623`",
        "operationId": "ffl_core.gunsmith.open_pickup",
        "responses": {
          "200": {
            "description": "{\"pos_invoice\", \"already\": bool} or {\"picked_up\": True, \"refund_due\": deposit still held, refunded with :func:`refund_deposit`}.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "name": {
                    "type": "string",
                    "description": "Gunsmith Work Order name; must be Ready."
                  }
                },
                "required": [
                  "name"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_core.gunsmith.refund_deposit": {
      "post": {
        "tags": [
          "ffl_core"
        ],
        "summary": "Open (or return) the draft register return that pays back the deposit still held",
        "description": "— a cancelled job's, or what a smaller bill left over. A return goes against one\npayment and refunds at most that payment, newest first; with several payments held\nthe rest is refunded with the next return.\n\n**Auth (derived from code):** Roles: Sales User / Sales Manager / Stock Manager / System Manager\n\nSource: `apps/ffl_core/ffl_core/gunsmith.py:690`",
        "operationId": "ffl_core.gunsmith.refund_deposit",
        "responses": {
          "200": {
            "description": "{\"pos_invoice\", \"already\": bool, \"amount\": what this return pays back}.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "name": {
                    "type": "string",
                    "description": "Gunsmith Work Order name; Cancelled or Picked Up, with deposit held."
                  }
                },
                "required": [
                  "name"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_core.gunsmith.register_work_orders": {
      "post": {
        "tags": [
          "ffl_core"
        ],
        "summary": "The open jobs for the register's Recent Orders › Work Orders list, with what its",
        "description": "Take payment and Complete actions need.\n\n**Auth (derived from code):** Roles: Sales User / Sales Manager / Stock Manager / System Manager\n\nSource: `apps/ffl_core/ffl_core/gunsmith.py:232`",
        "operationId": "ffl_core.gunsmith.register_work_orders",
        "responses": {
          "200": {
            "description": "{\"labor_item\", \"orders\": [{\"name\", \"customer\", \"customer_name\", \"status\", \"manufacturer\", \"model\", \"caliber\", \"serial_number\", \"work_requested\", \"work_performed\", \"estimated_cost\", \"deposit_held\", \"logged\", \"lines\": [{\"item_code\", \"description\", \"qty\", \"rate\"}], \"drafts\": {\"deposit\", \"pickup\", \"refund\"}, \"authorization\": the intake authorization's state (signed / pending / missing …) for an open job, else None}], \"authorization_template\"}: open jobs (Ready first), then closed ones still holding a payment to refund.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "search_term": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "description": "Part of the job's name, customer, gun or serial; optional."
                  },
                  "name": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "description": "One job only (the Desk form sending the clerk to the register); optional."
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_core.gunsmith.start_work": {
      "post": {
        "tags": [
          "ffl_core"
        ],
        "summary": "Received (or Ready, reopened) → In Progress.",
        "description": "**Auth (derived from code):** Roles: Sales User / Sales Manager / Stock Manager / System Manager\n\nSource: `apps/ffl_core/ffl_core/gunsmith.py:386`",
        "operationId": "ffl_core.gunsmith.start_work",
        "responses": {
          "200": {
            "description": "{\"status\"}.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "name": {
                    "type": "string",
                    "description": "Gunsmith Work Order name."
                  }
                },
                "required": [
                  "name"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_core.item_options.create_item_with_options": {
      "post": {
        "tags": [
          "ffl_core"
        ],
        "summary": "Create an item that comes in options: the template Item, any missing options (Item",
        "description": "Attributes) and values, and one variant Item per included combination — all or nothing.\n\nEach variant copies the template's shared fields once (group, brand, description, photos,\ntax and accounting defaults, flags) and has its own item code (its SKU), price (with the\nregister's Item Price), cost and pre-order slots. The template keeps no price, cost, UPC or\nstock of its own.\n\n**Auth (derived from code):** Requires create permission on Item (Frappe DocType permission check).\n\nSource: `apps/ffl_core/ffl_core/item_options.py:393`",
        "operationId": "ffl_core.item_options.create_item_with_options",
        "responses": {
          "200": {
            "description": "{\"template\": the template's item code, \"variants\": [the variants' item codes]}.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "item": {
                    "description": "The Item form's document (dict or JSON), as the form would save it. ``item_code`` is required."
                  },
                  "options": {
                    "description": "``[{name, values: [value, ...]}]`` in order (1–3 options); values in the order the storefront lists them. Names and values are matched to existing ones ignoring case."
                  },
                  "rows": {
                    "description": "``[{values: {option: value}, include, sku, price, cost, preorder, eta}]`` — one per combination; unticked rows (``include`` 0) are skipped. An included row needs a SKU (letters, numbers and ``. _ / -``, not an existing item code) and a price above 0."
                  }
                },
                "required": [
                  "item",
                  "options",
                  "rows"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_core.item_options.group_items": {
      "post": {
        "tags": [
          "ffl_core"
        ],
        "summary": "Group existing Items under an item that comes in options, each with its option values,",
        "description": "keeping their item codes. Nothing is written when any Item fails a check.\n\n**Auth (derived from code):** Requires write permission on Item (Frappe DocType permission check).\n\nSource: `apps/ffl_core/ffl_core/item_options.py:804`",
        "operationId": "ffl_core.item_options.group_items",
        "responses": {
          "200": {
            "description": "{\"ok\", \"errors\": [one line per problem], \"variants\": [the item codes grouped]}.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "template": {
                    "type": "string",
                    "description": "The Item that comes in options."
                  },
                  "variants": {
                    "description": "``{item_code: {option: value}}`` (dict or JSON); every option needs one of its existing values, and no two Items (nor an Item and an existing row) the same values."
                  }
                },
                "required": [
                  "template",
                  "variants"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_core.item_options.item_options_state": {
      "post": {
        "tags": [
          "ffl_core"
        ],
        "summary": "A saved item's options and one row per variant, for the Item form's panel.",
        "description": "**Auth (derived from code):** Requires read permission on Item (Frappe DocType permission check).\n\nSource: `apps/ffl_core/ffl_core/item_options.py:499`",
        "operationId": "ffl_core.item_options.item_options_state",
        "responses": {
          "200": {
            "description": "{\"template\", \"item_name\", \"preorder\": whether pre-order fields exist, \"options\": [{name, values: [in storefront order], abbr: {value: abbreviation}}], \"rows\": [{item_code, item_name, values: {option: value}, disabled, price, cost, preorder, eta}]}.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "template": {
                    "type": "string",
                    "description": "The Item that comes in options."
                  }
                },
                "required": [
                  "template"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_core.item_options.option_codes": {
      "post": {
        "tags": [
          "ffl_core"
        ],
        "summary": "The short code each value of an option has, or will get when saved — what the Item form",
        "description": "builds default SKUs from.\n\n**Auth (derived from code):** Requires read permission on Item (Frappe DocType permission check).\n\nSource: `apps/ffl_core/ffl_core/item_options.py:679`",
        "operationId": "ffl_core.item_options.option_codes",
        "responses": {
          "200": {
            "description": "{value: code} — an existing value's own code, a new value the code saving gives it.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "option": {
                    "type": "string",
                    "description": "The option (Item Attribute) name; it need not exist yet."
                  },
                  "values": {
                    "description": "The option's values in order (list or JSON)."
                  }
                },
                "required": [
                  "option",
                  "values"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_core.item_options.option_suggestions": {
      "post": {
        "tags": [
          "ffl_core"
        ],
        "summary": "Existing option names, or one option's values, for the Item form's typeahead.",
        "description": "**Auth (derived from code):** Requires read permission on Item (Frappe DocType permission check).\n\nSource: `apps/ffl_core/ffl_core/item_options.py:650`",
        "operationId": "ffl_core.item_options.option_suggestions",
        "responses": {
          "200": {
            "description": "[{\"value\", \"abbr\"?}] — option names without abbreviations.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "array"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "option": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "description": "An option (Item Attribute) name: its values are returned (in storefront order). Blank: option names."
                  },
                  "txt": {
                    "type": "string",
                    "description": "What was typed (matched anywhere, ignoring case).",
                    "default": ""
                  },
                  "limit": {
                    "description": "At most this many (default 20, up to 500).",
                    "default": 20
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_core.item_options.taken_item_codes": {
      "post": {
        "tags": [
          "ffl_core"
        ],
        "summary": "Which of *codes* are already item codes (ignoring case) — the Item form's SKU check.",
        "description": "**Auth (derived from code):** Requires read permission on Item (Frappe DocType permission check).\n\nSource: `apps/ffl_core/ffl_core/item_options.py:712`",
        "operationId": "ffl_core.item_options.taken_item_codes",
        "responses": {
          "200": {
            "description": "The ones that exist, as given.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "array"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "codes": {
                    "description": "Item codes (list or JSON), up to 500."
                  }
                },
                "required": [
                  "codes"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_core.item_options.update_option_rows": {
      "post": {
        "tags": [
          "ffl_core"
        ],
        "summary": "Save the panel of an item that comes in options: edits to existing rows, and new rows for",
        "description": "values added to its options — one transaction.\n\nAn existing row is saved through an ordinary Item save (so the website and GunBroker pushes\nrun); a new price also becomes the register's price. Unticking a row disables that variant —\nnever deletes it — and ticking it again enables it.\n\n**Auth (derived from code):** Requires write permission on Item (Frappe DocType permission check).\n\nSource: `apps/ffl_core/ffl_core/item_options.py:585`",
        "operationId": "ffl_core.item_options.update_option_rows",
        "responses": {
          "200": {
            "description": ":func:`item_options_state` after the save, plus ``\"created\"``: the new variants' item codes.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "template": {
                    "type": "string",
                    "description": "The Item that comes in options."
                  },
                  "rows": {
                    "description": "``[{item_code, include?, price?, cost?, preorder?, eta?}]`` for existing rows (only the keys sent change), and ``[{values: {option: value}, include, sku, price, cost, preorder, eta}]`` for new combinations (created when included; same checks as :func:`create_item_with_options`)."
                  },
                  "options": {
                    "description": "``[{name, values}]`` — the item's options in order with every value it shows, new ones included, in the order the storefront lists them (needed when new rows are sent; the option names can't change). Unused new values are kept on the option."
                  }
                },
                "required": [
                  "template",
                  "rows"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_core.marketing.providers.ses.notify": {
      "post": {
        "tags": [
          "webhooks"
        ],
        "summary": "Amazon SNS posts SES bounce and complaint notifications here (Guest).",
        "description": "The body is the SNS message (JSON, sent as text/plain). Refused with a 403 unless it comes from the\ntopic in Marketing Settings and its signature verifies. 10000 calls an hour per IP address.\n\n**Auth (derived from code):** Guest — no session; the endpoint verifies the caller itself (HMAC signature, HTTP Basic credentials or a one-time token).\n\nSource: `apps/ffl_core/ffl_core/marketing/providers/ses.py:60`",
        "operationId": "ffl_core.marketing.providers.ses.notify",
        "responses": {
          "200": {
            "description": "{\"type\": the SNS message type, \"processed\": how many addresses changed or were logged}."
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "security": []
      }
    },
    "/api/method/ffl_core.marketing.track.click": {
      "get": {
        "tags": [
          "webhooks"
        ],
        "summary": "A tracked link in a marketing mail (Guest): a redirect to *u*.",
        "description": "Only when *s* is this site's signature of *u* and *u* is an http(s) address; anything else gets a\n400 and no redirect. Records the contact's first click on that link in campaign *c* while Track\nclicks is on and the campaign was sent to them. 5000 calls an hour per IP address.\n\n**Auth (derived from code):** Guest — no session; the endpoint verifies the caller itself (HMAC signature, HTTP Basic credentials or a one-time token).\n\nSource: `apps/ffl_core/ffl_core/marketing/track.py:101`",
        "operationId": "ffl_core.marketing.track.click",
        "responses": {
          "200": {
            "description": "A 302 redirect to *u*, or a 400 plain-text \"This link is not valid.\""
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "security": [],
        "parameters": [
          {
            "name": "u",
            "in": "query",
            "required": false,
            "schema": {
              "type": [
                "string",
                "null"
              ]
            },
            "description": "Where the link goes."
          },
          {
            "name": "c",
            "in": "query",
            "required": false,
            "schema": {
              "type": [
                "string",
                "null"
              ]
            },
            "description": "The campaign."
          },
          {
            "name": "t",
            "in": "query",
            "required": false,
            "schema": {
              "type": [
                "string",
                "null"
              ]
            },
            "description": "The contact's token from the mail."
          },
          {
            "name": "s",
            "in": "query",
            "required": false,
            "schema": {
              "type": [
                "string",
                "null"
              ]
            },
            "description": "The signature of *u*."
          }
        ]
      }
    },
    "/api/method/ffl_core.marketing.track.open": {
      "get": {
        "tags": [
          "webhooks"
        ],
        "summary": "The open pixel of a marketing mail (Guest): always a 1x1 GIF.",
        "description": "Records the first open of campaign *c* by the contact *t* stands for, while Track opens is on and\nthe campaign was sent to them. 5000 calls an hour per IP address.\n\n**Auth (derived from code):** Guest — no session; the endpoint verifies the caller itself (HMAC signature, HTTP Basic credentials or a one-time token).\n\nSource: `apps/ffl_core/ffl_core/marketing/track.py:81`",
        "operationId": "ffl_core.marketing.track.open",
        "responses": {
          "200": {
            "description": "A 1x1 GIF image, never cached."
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "security": [],
        "parameters": [
          {
            "name": "c",
            "in": "query",
            "required": false,
            "schema": {
              "type": [
                "string",
                "null"
              ]
            },
            "description": "The campaign."
          },
          {
            "name": "t",
            "in": "query",
            "required": false,
            "schema": {
              "type": [
                "string",
                "null"
              ]
            },
            "description": "The contact's token from the mail."
          }
        ]
      }
    },
    "/api/method/ffl_core.membership.cancel_membership": {
      "post": {
        "tags": [
          "ffl_core"
        ],
        "summary": "Cancel a membership. By default it runs to the end of the period it is paid for and is not",
        "description": "renewed. ``end_now`` ends it today: the current invoice's deferred lines get today as their\nservice stop date, so what is still deferred becomes income today. The invoice itself is never\ncancelled; a refund is a credit note.\n\n**Auth (derived from code):** Roles: Sales Manager / System Manager\n\nSource: `apps/ffl_core/ffl_core/membership.py:607`",
        "operationId": "ffl_core.membership.cancel_membership",
        "responses": {
          "200": {
            "description": "The membership's panel row.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "membership": {
                    "type": "string",
                    "description": "Membership name (Active, Past Due or Suspended)."
                  },
                  "reason": {
                    "type": "string",
                    "description": "Why (kept on the membership)."
                  },
                  "end_now": {
                    "description": "1 to end it today instead of at the period end.",
                    "default": 0
                  }
                },
                "required": [
                  "membership",
                  "reason"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_core.membership.change_card": {
      "post": {
        "tags": [
          "ffl_core"
        ],
        "summary": "Charge a membership's renewals to another of the customer's cards saved for recurring",
        "description": "charges.\n\n**Auth (derived from code):** Roles: Sales User / Sales Manager / Stock Manager / System Manager\n\nSource: `apps/ffl_core/ffl_core/membership.py:581`",
        "operationId": "ffl_core.membership.change_card",
        "responses": {
          "200": {
            "description": "The membership's panel row.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "membership": {
                    "type": "string",
                    "description": "Membership name."
                  },
                  "saved_card": {
                    "type": "string",
                    "description": "Saved Card name: the customer's, active, saved for recurring charges."
                  }
                },
                "required": [
                  "membership",
                  "saved_card"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_core.membership.discard_membership": {
      "post": {
        "tags": [
          "ffl_core"
        ],
        "summary": "Drop a Pending membership the customer did not pay for. Its unpaid invoice is cancelled —",
        "description": "refused once any payment or card charge touched it.\n\n**Auth (derived from code):** Roles: Sales User / Sales Manager / Stock Manager / System Manager\n\nSource: `apps/ffl_core/ffl_core/membership.py:681`",
        "operationId": "ffl_core.membership.discard_membership",
        "responses": {
          "200": {
            "description": "The membership's panel row (status Cancelled).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "membership": {
                    "type": "string",
                    "description": "Membership name (Pending)."
                  },
                  "reason": {
                    "type": "string",
                    "description": "Why (kept on the membership)."
                  }
                },
                "required": [
                  "membership",
                  "reason"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_core.membership.get_memberships": {
      "post": {
        "tags": [
          "ffl_core"
        ],
        "summary": "A customer's memberships and the plans on sale, for the Customer form's Memberships panel.",
        "description": "A membership whose invoice has since been paid another way is settled here.\n\n**Auth (derived from code):** Roles: Sales User / Sales Manager / Stock Manager / System Manager / Accounts User / Accounts Manager\n\nSource: `apps/ffl_core/ffl_core/membership.py:468`",
        "operationId": "ffl_core.membership.get_memberships",
        "responses": {
          "200": {
            "description": "{plans: [{name, price, billing_period, registration_fee, auto_renew_default, terms_template}], memberships: [panel rows, live first; a row says whether its renewal is overdue, can be retried on the card, or has a card charge waiting], cards: the customer's active recurring-use saved cards [{name, card_summary}], can_cancel: whether the caller may cancel}.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "customer": {
                    "type": "string",
                    "description": "Customer name (document id)."
                  }
                },
                "required": [
                  "customer"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_core.membership.invoice_membership": {
      "post": {
        "tags": [
          "ffl_core"
        ],
        "summary": "Build and submit the Pending membership's first Sales Invoice (or hand back the unpaid one",
        "description": "already made), after the plan's terms are signed. The counter takes payment against it.\n\n**Auth (derived from code):** Roles: Sales User / Sales Manager / Stock Manager / System Manager\n\nSource: `apps/ffl_core/ffl_core/membership.py:239`",
        "operationId": "ffl_core.membership.invoice_membership",
        "responses": {
          "200": {
            "description": "{sales_invoice, outstanding, customer, auto_renew}.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "membership": {
                    "type": "string",
                    "description": "Membership name (Pending)."
                  }
                },
                "required": [
                  "membership"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_core.membership.invoice_renewal": {
      "post": {
        "tags": [
          "ffl_core"
        ],
        "summary": "The overdue renewal's invoice (the open one, else a new one for the next period from the",
        "description": "original due date), for the counter to take payment by any tender. Paid: Active again.\n\n**Auth (derived from code):** Roles: Sales User / Sales Manager / Stock Manager / System Manager\n\nSource: `apps/ffl_core/ffl_core/membership.py:1179`",
        "operationId": "ffl_core.membership.invoice_renewal",
        "responses": {
          "200": {
            "description": "{sales_invoice, outstanding, customer, auto_renew: 0 (no card charge from this flow)}.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "membership": {
                    "type": "string",
                    "description": "Membership name (Past Due, Suspended, or Active past its period end)."
                  }
                },
                "required": [
                  "membership"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_core.membership.needs_attention": {
      "post": {
        "tags": [
          "ffl_core"
        ],
        "summary": "Memberships a manager should look at: Past Due, Suspended, a renewal charge the gateway never",
        "description": "confirmed, a renewal the job could not charge, and sign-ups still unpaid after a few days.\n\n**Auth (derived from code):** Roles: Sales Manager / System Manager\n\nSource: `apps/ffl_core/ffl_core/membership.py:1229`",
        "operationId": "ffl_core.membership.needs_attention",
        "responses": {
          "200": {
            "description": "{renewals_on: whether the daily renewal job runs, rows: [{membership, customer, customer_name, plan, status, reason, detail, current_period_end, sales_invoice, outstanding, can_retry, can_cancel, can_drop}]}.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        }
      }
    },
    "/api/method/ffl_core.membership.page_members": {
      "post": {
        "tags": [
          "ffl_core"
        ],
        "summary": "One page of the Memberships page's member list, by customer name.",
        "description": "**Auth (derived from code):** Roles: Sales User / Sales Manager / Stock Manager / System Manager / Accounts User / Accounts Manager\n\nSource: `apps/ffl_core/ffl_core/membership.py:1419`",
        "operationId": "ffl_core.membership.page_members",
        "responses": {
          "200": {
            "description": "{rows: [{name, customer, customer_name, plan, status, next_charge_date, ends_on, auto_renew, card_summary}], more: whether another page follows}.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "plan": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "description": "Membership Plan name; blank = every plan."
                  },
                  "status": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "description": "Membership status; blank = every status."
                  },
                  "search": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "description": "Part of the customer's name, id or mobile number; blank = everyone."
                  },
                  "start": {
                    "type": "integer",
                    "description": "Rows to skip (paging, 50 a page).",
                    "default": 0
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_core.membership.page_overview": {
      "post": {
        "tags": [
          "ffl_core"
        ],
        "summary": "Everything the Memberships page shows above the member list, in one round trip.",
        "description": "**Auth (derived from code):** Roles: Sales User / Sales Manager / Stock Manager / System Manager / Accounts User / Accounts Manager\n\nSource: `apps/ffl_core/ffl_core/membership.py:1372`",
        "operationId": "ffl_core.membership.page_overview",
        "responses": {
          "200": {
            "description": "{plans: [{name, active, billing_period, price, registration_fee, auto_renew_default, grace_enabled, grace_days, terms_template, description, members, benefits: one line per member benefit}], totals: {active, monthly, renewing_soon, attention}, attention: the Needs attention answer (managers only, else null), can_manage: may act on memberships, can_edit_plans: may create and change plans}. ``monthly`` is what the Active and Past Due members bill per month (a yearly price counts a twelfth); ``renewing_soon`` counts auto-renewing Active members charged in the next 7 days.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        }
      }
    },
    "/api/method/ffl_core.membership.retry_renewal": {
      "post": {
        "tags": [
          "ffl_core"
        ],
        "summary": "Charge a membership's saved card now for its overdue renewal (Past Due, Suspended, or Active",
        "description": "past its period end). Paid: Active again, the new period starting at the original due date. A\ncard charge still waiting for the gateway's answer is looked up, never sent again.\n\n**Auth (derived from code):** Roles: Sales Manager / System Manager\n\nSource: `apps/ffl_core/ffl_core/membership.py:1150`",
        "operationId": "ffl_core.membership.retry_renewal",
        "responses": {
          "200": {
            "description": "{outcome: renewed / declined / unknown / not_started, message: what happened, row: the membership's panel row}.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "membership": {
                    "type": "string",
                    "description": "Membership name."
                  }
                },
                "required": [
                  "membership"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_core.membership.set_auto_renew": {
      "post": {
        "tags": [
          "ffl_core"
        ],
        "summary": "Turn a membership's auto-renew on or off. On needs a card saved for recurring charges",
        "description": "(the membership's own, else the customer's default one); a membership ending at period end\nis a manager's cancellation and stays off.\n\n**Auth (derived from code):** Roles: Sales User / Sales Manager / Stock Manager / System Manager\n\nSource: `apps/ffl_core/ffl_core/membership.py:539`",
        "operationId": "ffl_core.membership.set_auto_renew",
        "responses": {
          "200": {
            "description": "The membership's panel row.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "membership": {
                    "type": "string",
                    "description": "Membership name."
                  },
                  "enabled": {
                    "description": "1 to renew automatically, 0 not to."
                  }
                },
                "required": [
                  "membership",
                  "enabled"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_core.membership.start_membership": {
      "post": {
        "tags": [
          "ffl_core"
        ],
        "summary": "Start selling a membership: the customer's Pending membership of the plan (a Pending one",
        "description": "already there is picked up again, with the new auto-renew choice).\n\n**Auth (derived from code):** Roles: Sales User / Sales Manager / Stock Manager / System Manager\n\nSource: `apps/ffl_core/ffl_core/membership.py:181`",
        "operationId": "ffl_core.membership.start_membership",
        "responses": {
          "200": {
            "description": "The panel row of the membership ({name, plan, status, auto_renew, terms_template, terms_state, ...}).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "customer": {
                    "type": "string",
                    "description": "Customer name (document id); not the walk-in customer."
                  },
                  "plan": {
                    "type": "string",
                    "description": "Membership Plan name; must be active."
                  },
                  "auto_renew": {
                    "description": "1 / 0; blank = the plan's default."
                  }
                },
                "required": [
                  "customer",
                  "plan"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_core.membership_benefits.preview": {
      "post": {
        "tags": [
          "ffl_core"
        ],
        "summary": "The member prices a save would give a register sale, for the screen to show at once.",
        "description": "**Auth (derived from code):** Roles: Sales User / Sales Manager / Stock Manager / System Manager\n\nSource: `apps/ffl_core/ffl_core/membership_benefits.py:989`",
        "operationId": "ffl_core.membership_benefits.preview",
        "responses": {
          "200": {
            "description": "{\"rows\": {line name: {\"rate\", \"price_list_rate\", \"discount_percentage\", \"discount_amount\", \"ffl_member_benefit\", \"ffl_membership\", \"ffl_benefit_customer\", \"ffl_member_rate\", \"ffl_discount_reason\"}}, \"notices\": [str]}. The save works it out again; nothing is stored.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "doc": {
                    "description": "The POS Invoice / Sales Invoice as JSON, as on the screen."
                  }
                },
                "required": [
                  "doc"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_core.preorder.assign_serial": {
      "post": {
        "tags": [
          "ffl_core"
        ],
        "summary": "Put another gun of the same item by for one line of an open pre-order (the one it had goes",
        "description": "back on the shelf), or a first one when none has arrived for it.\n\n**Auth (derived from code):** Roles: Sales User / Sales Manager / Stock Manager / System Manager\n\nSource: `apps/ffl_core/ffl_core/preorder.py:663`",
        "operationId": "ffl_core.preorder.assign_serial",
        "responses": {
          "200": {
            "description": "{\"serial\": the gun now put by, \"was\": the one it had or None}.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "sales_order": {
                    "type": "string",
                    "description": "The pre-order (open, not handed over)."
                  },
                  "row": {
                    "type": "string",
                    "description": "Its Sales Order Item row."
                  },
                  "serial": {
                    "type": "string",
                    "description": "A gun of that item on our shelf that nothing holds."
                  }
                },
                "required": [
                  "sales_order",
                  "row",
                  "serial"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_core.preorder.cancel_preorder": {
      "post": {
        "tags": [
          "ffl_core"
        ],
        "summary": "Cancel a pre-order and pay back everything held for it: the order is cancelled, its",
        "description": "quantities go back on the items, and each payment gets a draft return for its full amount, the\nway it was paid. The register checks the returns out.\n\n**Auth (derived from code):** Roles: Sales User / Sales Manager / Stock Manager / System Manager\n\nSource: `apps/ffl_core/ffl_core/preorder.py:815`",
        "operationId": "ffl_core.preorder.cancel_preorder",
        "responses": {
          "200": {
            "description": "{\"cancelled\": True, \"refunds\": [{\"pos_invoice\", \"amount\"}]}.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "sales_order": {
                    "type": "string",
                    "description": "The pre-order (submitted, nothing handed over)."
                  },
                  "reason": {
                    "type": "string",
                    "description": "Why."
                  }
                },
                "required": [
                  "sales_order",
                  "reason"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_core.preorder.create_preorder": {
      "post": {
        "tags": [
          "ffl_core"
        ],
        "summary": "Take a pre-order at the counter: a submitted Sales Order marked as one, its quantities taken",
        "description": "from the items' pre-order counts. No invoice and no money yet — payments go through\n:func:`open_payment`. The customer collects here.\n\n**Auth (derived from code):** Roles: Sales User / Sales Manager / Stock Manager / System Manager\n\nSource: `apps/ffl_core/ffl_core/preorder.py:315`",
        "operationId": "ffl_core.preorder.create_preorder",
        "responses": {
          "200": {
            "description": "{\"sales_order\", \"customer\", \"grand_total\": what the order comes to with tax, \"eta\"}.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "payload": {
                    "description": "{customer, items: [{item_code, qty, rate}], notes?, pos_profile?, price_approval?} — dict or JSON string. A serial-numbered item is one unit per line. Every item must have pre-order slots left and none on our shelves."
                  }
                },
                "required": [
                  "payload"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_core.preorder.list_preorders": {
      "post": {
        "tags": [
          "ffl_core"
        ],
        "summary": "Pre-orders for the Pending Order page: open ones waiting for their goods (stage ``waiting``) or",
        "description": "with everything here (``ready_pickup``), and cancelled or handed-over ones still holding money to\npay back (``blocked``).\n\n**Auth (derived from code):** Roles: Sales User / Sales Manager / Stock Manager / System Manager\n\nSource: `apps/ffl_core/ffl_core/preorder.py:887`",
        "operationId": "ffl_core.preorder.list_preorders",
        "responses": {
          "200": {
            "description": "[{\"source\": \"preorder\", \"sales_order\", \"customer\", \"customer_name\", \"posting_date\", \"grand_total\", \"held\", \"outstanding_amount\", \"paid\", \"cancelled\", \"handed_over\", \"ready\", \"eta\", \"items\": [{\"row\", \"item_code\", \"item_name\", \"qty\", \"serial\", \"reserved\", \"kind\", \"ready\"}], \"drafts\": {\"payment\", \"pickup\", \"refunds\": [...]}, \"stage\", \"blocked_reason\", \"age_days\", \"overdue\"}].",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "array"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "customer": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "description": "Only this customer's. Default: everyone's."
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_core.preorder.open_payment": {
      "post": {
        "tags": [
          "ffl_core"
        ],
        "summary": "A payment towards a pre-order, as a draft register invoice the register checks out (any",
        "description": "tender). One open payment draft per order: a second call returns the one already open.\n\n**Auth (derived from code):** Roles: Sales User / Sales Manager / Stock Manager / System Manager\n\nSource: `apps/ffl_core/ffl_core/preorder.py:412`",
        "operationId": "ffl_core.preorder.open_payment",
        "responses": {
          "200": {
            "description": "{\"pos_invoice\", \"already\": bool, \"amount\": the draft's payment amount, \"notice\": for a draft already open at another amount, the sentence that says so (shown before it opens), else None}.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "sales_order": {
                    "type": "string",
                    "description": "The pre-order (submitted)."
                  },
                  "amount": {
                    "type": "number",
                    "description": "What the customer pays now: above 0, no more than the order's total with tax less what is already held."
                  }
                },
                "required": [
                  "sales_order",
                  "amount"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_core.preorder.open_pickup": {
      "post": {
        "tags": [
          "ffl_core"
        ],
        "summary": "Hand an arrived pre-order over: the draft register ticket with its goods at the order's",
        "description": "prices, taxed as any sale today, and what is held coming off them (:func:`fit_release`). The\nregister takes the rest and the gun's 4473; the ticket's submit hands the order over.\n\n**Auth (derived from code):** Roles: Sales User / Sales Manager / Stock Manager / System Manager\n\nSource: `apps/ffl_core/ffl_core/preorder.py:709`",
        "operationId": "ffl_core.preorder.open_pickup",
        "responses": {
          "200": {
            "description": "{\"pos_invoice\", \"already\": bool (the ticket was open already)}.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "sales_order": {
                    "type": "string",
                    "description": "An open pre-order whose goods are all here."
                  }
                },
                "required": [
                  "sales_order"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_core.preorder.preorder_options": {
      "post": {
        "tags": [
          "ffl_core"
        ],
        "summary": "Whether Create Order may offer *item_code* as a pre-order line: pre-order slots left and none",
        "description": "on our shelves.\n\n**Auth (derived from code):** Roles: Sales User / Sales Manager / Stock Manager / System Manager\n\nSource: `apps/ffl_core/ffl_core/preorder.py:288`",
        "operationId": "ffl_core.preorder.preorder_options",
        "responses": {
          "200": {
            "description": "{\"available\": slots left, \"eta\": the expected date or None, \"in_stock\": units on our shelves, \"can_preorder\": bool}.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "item_code": {
                    "type": "string",
                    "description": "The Item."
                  },
                  "company": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "description": "The order's company; else the default one."
                  }
                },
                "required": [
                  "item_code"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_core.preorder.refund_preorder": {
      "post": {
        "tags": [
          "ffl_core"
        ],
        "summary": "The draft returns paying back what a pre-order still holds once it is cancelled, or handed over",
        "description": "for less than was paid — the open ones, or new ones for every payment not returned yet.\n\n**Auth (derived from code):** Roles: Sales User / Sales Manager / Stock Manager / System Manager\n\nSource: `apps/ffl_core/ffl_core/preorder.py:847`",
        "operationId": "ffl_core.preorder.refund_preorder",
        "responses": {
          "200": {
            "description": "{\"refunds\": [{\"pos_invoice\", \"amount\"}]}.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "sales_order": {
                    "type": "string",
                    "description": "A cancelled or handed-over pre-order."
                  }
                },
                "required": [
                  "sales_order"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_core.preorder.serial_choices": {
      "post": {
        "tags": [
          "ffl_core"
        ],
        "summary": "The guns a pre-order's lines could have: for each serial-numbered line, the one put by for it",
        "description": "and every other of the same item on our shelf that nothing holds.\n\n**Auth (derived from code):** Roles: Sales User / Sales Manager / Stock Manager / System Manager\n\nSource: `apps/ffl_core/ffl_core/preorder.py:633`",
        "operationId": "ffl_core.preorder.serial_choices",
        "responses": {
          "200": {
            "description": "{\"lines\": [{\"row\", \"item_code\", \"item_name\", \"serial\", \"choices\": [serial, ...]}]}.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "sales_order": {
                    "type": "string",
                    "description": "An open pre-order."
                  }
                },
                "required": [
                  "sales_order"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_core.price_approval.approve": {
      "post": {
        "tags": [
          "ffl_core"
        ],
        "summary": "A manager approves the lowered prices of a sale, or a return, before it is saved.",
        "description": "The approver picks themselves and types their own counter PIN, or their password when they\nhave no PIN (or it is off). What is approved is worked out here from the same document, never\ntaken from the screen. The token is good for 15 minutes, once, for the user who asked.\n\n**Auth (derived from code):** Roles: Sales User / Sales Manager / Stock Manager / System Manager / Accounts User / Accounts Manager\n\nSource: `apps/ffl_core/ffl_core/price_approval.py:700`",
        "operationId": "ffl_core.price_approval.approve",
        "responses": {
          "200": {
            "description": "{\"token\", \"approver\", \"approver_name\", \"expires_in\": seconds, \"lines\", \"discount\", \"refund\"}.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "approver": {
                    "type": "string",
                    "description": "The manager's user id (from :func:`check`'s approvers)."
                  },
                  "reason": {
                    "type": "string",
                    "description": "Why (required; kept on the document and its timeline)."
                  },
                  "pin": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "description": "The approver's counter PIN."
                  },
                  "password": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "description": "Or their password."
                  },
                  "doc": {
                    "description": "The form's document as JSON (as :func:`check`)."
                  },
                  "payload": {
                    "description": "Or a Create Order payload."
                  },
                  "sales_invoice": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "description": "With *payload*: the order it edits."
                  }
                },
                "required": [
                  "approver",
                  "reason"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_core.price_approval.check": {
      "post": {
        "tags": [
          "ffl_core"
        ],
        "summary": "What a save would need a manager for — the screens ask before saving.",
        "description": "**Auth (derived from code):** Roles: Sales User / Sales Manager / Stock Manager / System Manager / Accounts User / Accounts Manager\n\nSource: `apps/ffl_core/ffl_core/price_approval.py:652`",
        "operationId": "ffl_core.price_approval.check",
        "responses": {
          "200": {
            "description": "{\"needs_approval\": bool, \"approver\": whether the caller approves their own, \"lines\": [{\"idx\", \"item_code\", \"item_name\", \"serial\", \"list_rate\", \"rate\"}], \"discount\": {\"percentage\", \"amount\"} or None, \"refund\": a return's {\"total\", \"lines\": [{\"item_code\", \"item_name\", \"serial\", \"qty\", \"amount\"}]} or None, \"approvers\": [{\"user\", \"full_name\", \"image\", \"has_pin\", \"pin_off\"}] when it needs one}.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "doc": {
                    "description": "The form's document (POS Invoice, Sales Invoice or Sales Order) as JSON."
                  },
                  "payload": {
                    "description": "Or a Create Order payload (create_order's shape)."
                  },
                  "sales_invoice": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "description": "With *payload*: the order it edits (its lines keep their prices)."
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_core.reservations.reserved_counter_serials": {
      "post": {
        "tags": [
          "ffl_core"
        ],
        "summary": "Counter-hold registry for one Item's in-stock serials — the DISPLAY half.",
        "description": "Drives the Pending pill on the Item form's Serial Numbers tab. Same data as\n:func:`counter_holds`, behind the shipping-role gate, because it names which\nregulated serials sit on which order.\n\n**Auth (derived from code):** Role-filtered: callers without Roles Sales User / Sales Manager / Stock Manager / System Manager receive an EMPTY result instead of an error.\n\n**Permissions:** Canonical shipping roles. A caller WITHOUT the role gets an empty {} back silently — no error is raised — so an empty result from THIS function is not proof of \"no holds\". Anything enforcing a rule must call :func:`counter_holds` instead; see its docstring for what went wrong when that distinction did not exist.\n\nSource: `apps/ffl_core/ffl_core/reservations.py:213`",
        "operationId": "ffl_core.reservations.reserved_counter_serials",
        "responses": {
          "200": {
            "description": "{serial: {source, ref, kind, tooltip, url}} — only held serials appear.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "item_code": {
                    "type": "string",
                    "description": "Item whose in-stock serials to check."
                  }
                },
                "required": [
                  "item_code"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_core.signing_terminal.list_terminals": {
      "post": {
        "tags": [
          "ffl_core"
        ],
        "summary": "Active signing tablets, for the Request agreement dialog.",
        "description": "**Auth (derived from code):** Any authenticated user — no explicit role gate at function entry (deliberate open reads document this in Permissions).\n\nSource: `apps/ffl_core/ffl_core/signing_terminal.py:103`",
        "operationId": "ffl_core.signing_terminal.list_terminals",
        "responses": {
          "200": {
            "description": "[{\"name\", \"pos_profile\", \"paired\"}], by name.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "array"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        }
      }
    },
    "/api/method/ffl_core.signing_terminal.pair_terminal": {
      "post": {
        "tags": [
          "webhooks"
        ],
        "summary": "The tablet trades a pairing code for its device key (Guest).",
        "description": "The code works once. Any tablet paired to the same terminal before stops\nworking. 10 tries per 10 minutes per IP address; after 50 wrong codes from\nanywhere in 10 minutes, pairing pauses until the window passes.\n\n**Auth (derived from code):** Guest — no session; the endpoint verifies the caller itself (HMAC signature, HTTP Basic credentials or a one-time token).\n\nSource: `apps/ffl_core/ffl_core/signing_terminal.py:135`",
        "operationId": "ffl_core.signing_terminal.pair_terminal",
        "responses": {
          "200": {
            "description": "{\"secret\": the device key (shown this once), \"terminal_name\"}.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "security": [],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "code": {
                    "type": "string",
                    "description": "The 6 digits shown on the Signing Terminal record."
                  }
                },
                "required": [
                  "code"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_core.signing_terminal.start_pairing": {
      "post": {
        "tags": [
          "ffl_core"
        ],
        "summary": "Manager starts pairing a tablet: a 6-digit code to type on it.",
        "description": "**Auth (derived from code):** Roles: Sales Manager / System Manager\n\nSource: `apps/ffl_core/ffl_core/signing_terminal.py:114`",
        "operationId": "ffl_core.signing_terminal.start_pairing",
        "responses": {
          "200": {
            "description": "{\"code\", \"expires_in_minutes\", \"page\": the URL to open on the tablet}.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "terminal": {
                    "type": "string",
                    "description": "Signing Terminal name; must be active."
                  }
                },
                "required": [
                  "terminal"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_core.signing_terminal.terminal_poll": {
      "post": {
        "tags": [
          "webhooks"
        ],
        "summary": "What the tablet should show now (Guest, every 2 seconds).",
        "description": "Limited per tablet (2400 an hour) and per IP address (30000 an hour: a shop's\ntablets together, about 16 of them polling all hour).\n\n**Auth (derived from code):** Guest — no session; the endpoint verifies the caller itself (HMAC signature, HTTP Basic credentials or a one-time token).\n\nSource: `apps/ffl_core/ffl_core/signing_terminal.py:182`",
        "operationId": "ffl_core.signing_terminal.terminal_poll",
        "responses": {
          "200": {
            "description": "{\"paired\": false} for an unknown or switched-off tablet (the page goes back to pairing); {\"paired\": true, \"token\"} when the counter sent a link (handed out once); {\"paired\": true, \"url\"} when it sent the tablet to a page of this site (handed out once); otherwise {\"paired\": true, \"idle\": true, \"terminal_name\", \"store_name\", \"form_4473_url\"} — form_4473_url is the store's FastBound customer 4473 page, or \"\" when the store has no electronic 4473.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "security": [],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "secret": {
                    "type": "string",
                    "description": "The tablet's device key."
                  }
                },
                "required": [
                  "secret"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_core.staff_switch.clear_pin": {
      "post": {
        "tags": [
          "ffl_core"
        ],
        "summary": "Clear someone's counter PIN (they sign in with the password, and may set a new one).",
        "description": "**Auth (derived from code):** Roles: Sales Manager / System Manager\n\nSource: `apps/ffl_core/ffl_core/staff_switch.py:249`",
        "operationId": "ffl_core.staff_switch.clear_pin",
        "responses": {
          "200": {
            "description": "{\"has_pin\": False}.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "user": {
                    "type": "string",
                    "description": "The user whose PIN goes."
                  }
                },
                "required": [
                  "user"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_core.staff_switch.counter_users": {
      "post": {
        "tags": [
          "ffl_core"
        ],
        "summary": "Everyone who can sign in at the counter, for the switch-user list.",
        "description": "**Auth (derived from code):** Roles: Sales User / Sales Manager / Stock Manager / System Manager\n\nSource: `apps/ffl_core/ffl_core/staff_switch.py:84`",
        "operationId": "ffl_core.staff_switch.counter_users",
        "responses": {
          "200": {
            "description": "[{\"user\", \"full_name\", \"image\", \"current\": bool, \"has_pin\": bool, \"pin_off\": bool (five wrong PINs: their password until they next use it)}] for enabled desk users holding a counter role, by name (never Administrator, the site's superuser), and always the signed-in one, marked current: a locked screen is unlocked by picking yourself, whatever your roles.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "array"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        }
      }
    },
    "/api/method/ffl_core.staff_switch.lock_screen": {
      "post": {
        "tags": [
          "ffl_core"
        ],
        "summary": "Lock this session's screen (idle, or the clerk walked away).",
        "description": "**Auth (derived from code):** Roles: Sales User / Sales Manager / Stock Manager / System Manager\n\nSource: `apps/ffl_core/ffl_core/staff_switch.py:100`",
        "operationId": "ffl_core.staff_switch.lock_screen",
        "responses": {
          "200": {
            "description": "{\"locked\": 1}.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        }
      }
    },
    "/api/method/ffl_core.staff_switch.set_pin": {
      "post": {
        "tags": [
          "ffl_core"
        ],
        "summary": "Set (or change) the signed-in user's counter PIN.",
        "description": "**Auth (derived from code):** Roles: Sales User / Sales Manager / Stock Manager / System Manager\n\nSource: `apps/ffl_core/ffl_core/staff_switch.py:225`",
        "operationId": "ffl_core.staff_switch.set_pin",
        "responses": {
          "200": {
            "description": "{\"has_pin\": True}.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "password": {
                    "type": "string",
                    "description": "Their login password."
                  },
                  "pin": {
                    "type": "string",
                    "description": "The new PIN, 4–6 digits, not 1111 / 1234-style."
                  },
                  "confirm": {
                    "type": "string",
                    "description": "The new PIN again."
                  }
                },
                "required": [
                  "password",
                  "pin",
                  "confirm"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_core.staff_switch.switch_with_pin": {
      "post": {
        "tags": [
          "ffl_core"
        ],
        "summary": "Sign someone else in at this counter with their PIN: a new session for them",
        "description": "(frappe's LoginManager, so the login history records it, and its IP / hours rules\napply) and this one ends. Only a counter user who has a PIN, without a second sign-in\nstep; anyone else signs in with their password (frappe's login).\n\n**Auth (derived from code):** Roles: Sales User / Sales Manager / Stock Manager / System Manager\n\nSource: `apps/ffl_core/ffl_core/staff_switch.py:265`",
        "operationId": "ffl_core.staff_switch.switch_with_pin",
        "responses": {
          "200": {
            "description": "{\"user\"}.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "user": {
                    "type": "string",
                    "description": "Who is taking over the counter."
                  },
                  "pin": {
                    "type": "string",
                    "description": "Their counter PIN."
                  }
                },
                "required": [
                  "user",
                  "pin"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_core.staff_switch.unlock_screen": {
      "post": {
        "tags": [
          "ffl_core"
        ],
        "summary": "The signed-in person unlocks their own screen with their password (10 wrong",
        "description": "tries per person per 10 minutes, counted per person, not per IP — a shop's\ncounters share one address) or their counter PIN (5 wrong ones turn it off).\nSigning in as someone else is frappe's login, or :func:`switch_with_pin`.\n\n**Auth (derived from code):** Roles: Sales User / Sales Manager / Stock Manager / System Manager\n\nSource: `apps/ffl_core/ffl_core/staff_switch.py:112`",
        "operationId": "ffl_core.staff_switch.unlock_screen",
        "responses": {
          "200": {
            "description": "{\"locked\": 0}.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "password": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "description": "The signed-in user's password."
                  },
                  "pin": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "description": "Or their counter PIN."
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_integrations.atf.ez_check.lookup_and_create": {
      "post": {
        "tags": [
          "ffl_integrations"
        ],
        "summary": "Live-verify an FFL number via the configured EZ Check provider and",
        "description": "upsert the result into ATF FFL Record. Used by the \"+ Lookup by FFL #\"\nbutton on the ATF FFL Record list view to seed a new row in one click.\n\n**Auth (derived from code):** Roles: Sales User / Sales Manager / Stock Manager / System Manager\n\nSource: `apps/ffl_integrations/ffl_integrations/atf/ez_check.py:124`",
        "operationId": "ffl_integrations.atf.ez_check.lookup_and_create",
        "responses": {
          "200": {
            "description": "{ok, found, status, name, licensee_name, licensee_dba, license_type, expiry_date, address, street, street2, city, state, zip}.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "ffl_number": {
                    "type": "string",
                    "description": "FFL number (separators tolerated; loose format check)."
                  }
                },
                "required": [
                  "ffl_number"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_integrations.atf.ez_check.re_verify_all": {
      "post": {
        "tags": [
          "ffl_integrations"
        ],
        "summary": "Re-run live EZ Check for every ATF FFL Record.",
        "description": "Useful after the scraper / cache schema changes (e.g. License Type\nderivation, address column persistence) so existing rows are filled in\nwithout manual clicks. Skips gracefully when a row no longer exists\nupstream.\n\n**Auth (derived from code):** Roles: System Manager\n\nSource: `apps/ffl_integrations/ffl_integrations/atf/ez_check.py:90`",
        "operationId": "ffl_integrations.atf.ez_check.re_verify_all",
        "responses": {
          "200": {
            "description": "{updated, not_found, failed, total, errors: [\"<record>: <error>\", ...]}. not_found counts rows EZ Check did not list (C&R records are left as entered; a dealer's expiry is voided).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        }
      }
    },
    "/api/method/ffl_integrations.atf.ez_check_api.verify_customer_ffl": {
      "post": {
        "tags": [
          "ffl_integrations"
        ],
        "summary": "Live-verify a dealer customer's FFL and stamp the result on the Customer.",
        "description": "Customer-side mirror of verify_supplier_ffl: stamps\nstatus/licensee/expiry onto the Customer. The dealer-shipment gate\n(ffl_core.compliance.dealer_transfer) requires Verified + unexpired\nbefore firearms may ship to this customer. A provider outage stamps\nstatus \"Failed\" rather than raising.\n\n**Auth (derived from code):** Roles: Stock Manager / System Manager\n\nSource: `apps/ffl_integrations/ffl_integrations/atf/ez_check_api.py:47`",
        "operationId": "ffl_integrations.atf.ez_check_api.verify_customer_ffl",
        "responses": {
          "200": {
            "description": "{ok, status, licensee_name, expiry_date}.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "customer_name": {
                    "type": "string",
                    "description": "Customer with a non-empty ffl_number."
                  }
                },
                "required": [
                  "customer_name"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_integrations.atf.ez_check_api.verify_own_ffl": {
      "post": {
        "tags": [
          "ffl_integrations"
        ],
        "summary": "Live-verify the store's own FFL (FFL Settings → Our FFL Licence Number).",
        "description": "The Test Connection of the FFL Settings form: exercises the configured\nprovider end to end without stamping anything. Provider outages come\nback as status \"Failed\" with the reason rather than a traceback.\n\n**Auth (derived from code):** Roles: System Manager\n\nSource: `apps/ffl_integrations/ffl_integrations/atf/ez_check_api.py:85`",
        "operationId": "ffl_integrations.atf.ez_check_api.verify_own_ffl",
        "responses": {
          "200": {
            "description": "{ok, status, licensee_name, expiry_date, error}. ``ok`` is true only for status \"Verified\".",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        }
      }
    },
    "/api/method/ffl_integrations.atf.ez_check_api.verify_supplier_ffl": {
      "post": {
        "tags": [
          "ffl_integrations"
        ],
        "summary": "Live-verify a supplier's FFL and stamp the result on the Supplier.",
        "description": "The Verify FFL button on the Supplier form. Stamps\nez_check_status/licensee/expiry; a provider outage stamps status\n\"Failed\" rather than raising.\n\n**Auth (derived from code):** Roles: Stock Manager / System Manager\n\nSource: `apps/ffl_integrations/ffl_integrations/atf/ez_check_api.py:67`",
        "operationId": "ffl_integrations.atf.ez_check_api.verify_supplier_ffl",
        "responses": {
          "200": {
            "description": "{ok, status, licensee_name, expiry_date}.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "supplier_name": {
                    "type": "string",
                    "description": "Supplier with a non-empty ffl_number."
                  }
                },
                "required": [
                  "supplier_name"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_integrations.atf.search.search": {
      "post": {
        "tags": [
          "ffl_integrations"
        ],
        "summary": "Search the FFL directory (national listing + local cache).",
        "description": "Matches `query` exactly against ffl_number; otherwise searches the\nshared national listing (when configured) merged with the local cache,\nfalling back to a local LIKE.\n\n**Auth (derived from code):** Roles: Sales User / Sales Manager / Stock Manager / System Manager\n\nSource: `apps/ffl_integrations/ffl_integrations/atf/search.py:75`",
        "operationId": "ffl_integrations.atf.search.search",
        "responses": {
          "200": {
            "description": "Up to `limit` FFL record dicts.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "array"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "query": {
                    "type": "string",
                    "description": "FFL number or name/city substring (blank returns [])."
                  },
                  "limit": {
                    "type": "integer",
                    "description": "Row cap, clamped to 1–200 (default 20).",
                    "default": 20
                  }
                },
                "required": [
                  "query"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_integrations.catalog_master.m3_resync": {
      "post": {
        "tags": [
          "ffl_integrations"
        ],
        "summary": "Move the Items already on file onto the catalog master's categories (SPEC M3b).",
        "description": "Every enabled catalog Item that is not serialized is filed under its master\ncategory (``Catalog Category``) and, where the tree names a group it may use,\nthat category's Item Group; its store products are re-categorised (category\nonly). Serialized Items, firearms and firearm groups are never moved; a legal\ndifference is listed, never applied. ``dry_run`` (default) changes nothing and\nalso lists what the category mirror would do on each store.\n\n**Auth (derived from code):** Roles: System Manager\n\n**Permissions:** System Manager.\n\nSource: `apps/ffl_integrations/ffl_integrations/catalog_master.py:715`",
        "operationId": "ffl_integrations.catalog_master.m3_resync",
        "responses": {
          "200": {
            "description": "{items: [{item, item_name, old_group, new_group, old_category, new_category, issues}], moves: {\"old → new\": count}, counts: {checked, catalog, changes, serialized_skipped, not_in_master, review}, stores: {site: {actions, issues, unlinked_terms}}, token}; applying adds queued: true (failures land in the Error Log, the rest go on) and re-baselines the product-changes cursor.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "dry_run": {
                    "type": "integer",
                    "description": "1 (default) reports only; 0 applies the reported moves in a background job (the category mirror must be in Apply).",
                    "default": 1
                  },
                  "token": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "description": "Applying only — the dry run's ``token``. The plan is recomputed and must still be exactly the one the dry run showed, else nothing is done."
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_integrations.catalog_master.run_category_mirror": {
      "post": {
        "tags": [
          "ffl_integrations"
        ],
        "summary": "Settings button: run the category mirror now, in its current mode.",
        "description": "**Auth (derived from code):** Roles: System Manager\n\n**Permissions:** System Manager.\n\nSource: `apps/ffl_integrations/ffl_integrations/catalog_master.py:474`",
        "operationId": "ffl_integrations.catalog_master.run_category_mirror",
        "responses": {
          "200": {
            "description": "{queued: true} — the run is a background job; its report lands on the settings' Categories tab.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "full": {
                    "type": "integer",
                    "description": "1 re-reads the whole tree instead of the changes since the last run.",
                    "default": 0
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_integrations.data_service.get_capabilities": {
      "post": {
        "tags": [
          "ffl_integrations"
        ],
        "summary": "The site's capabilities, for desk pages that refresh without a reload.",
        "description": "**Auth (derived from code):** Any authenticated user — no explicit role gate at function entry (deliberate open reads document this in Permissions).\n\n**Permissions:** Any signed-in user (it names features, no data).\n\nSource: `apps/ffl_integrations/ffl_integrations/data_service/__init__.py:218`",
        "operationId": "ffl_integrations.data_service.get_capabilities",
        "responses": {
          "200": {
            "description": "{catalog: \"data_service\"|\"local\"|\"off\", category_tree: \"data_service\"|\"off\", ffl_national_search: \"data_service\"|\"not_chosen\"|\"off\", extension_updates: \"data_service\"|\"off\", ai: \"connected\"|\"off\"} — any of them \"unknown\" when its settings could not be read; the same dict as ``frappe.boot.ffl_capabilities``.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        }
      }
    },
    "/api/method/ffl_integrations.distributor.api.cancel_order": {
      "post": {
        "tags": [
          "ffl_integrations"
        ],
        "summary": "Cancel a Distributor Order here (alerts ops when it is still live at the house).",
        "description": "Cancelling never reaches the distributor, so an order that is live there\n(Placed+) has to be cancelled with the house by phone or email.\nLeft unconfirmed, ops are alerted to arrange that; ``confirmed`` records\nthat the house has already agreed and skips the alert.\n\n**Auth (derived from code):** Roles: Purchase Manager / Purchase User / Stock Manager / System Manager / Distributor Console\n\n**Permissions:** Distributor order/console roles.\n\nSource: `apps/ffl_integrations/ffl_integrations/distributor/api.py:1130`",
        "operationId": "ffl_integrations.distributor.api.cancel_order",
        "responses": {
          "200": {
            "description": "{\"name\": ..., \"status\": \"Cancelled\"}.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "do_name": {
                    "type": "string",
                    "description": "Distributor Order name."
                  },
                  "reason": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "description": "Optional reason, stored as hold_reason."
                  },
                  "confirmed": {
                    "description": "The distributor has confirmed the cancellation (phone / email); no ops alert, and a standard reason when none is given.",
                    "default": false
                  }
                },
                "required": [
                  "do_name"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_integrations.distributor.api.catalog_by_upc": {
      "post": {
        "tags": [
          "ffl_integrations"
        ],
        "summary": "The enabled houses' catalog rows for one UPC — the Receive Goods page's",
        "description": "fallback when a scanned barcode matches no Item, so the Item can be created\nfrom the catalog instead of typed.\n\n**Auth (derived from code):** Any authenticated user — no explicit role gate at function entry (deliberate open reads document this in Permissions).\n\n**Permissions:** Open read for any signed-in desk user (same as `search`).\n\nSource: `apps/ffl_integrations/ffl_integrations/distributor/api.py:224`",
        "operationId": "ffl_integrations.distributor.api.catalog_by_upc",
        "responses": {
          "200": {
            "description": "[{distributor, sku, upc, item_name, manufacturer, model, cost, map, msrp, qty, ffl_required, department, image_url}] — one row per house that lists it; a house whose catalog is down is simply absent.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "array"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "upc": {
                    "type": "string",
                    "description": "The scanned barcode."
                  }
                },
                "required": [
                  "upc"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_integrations.distributor.api.check_availability": {
      "post": {
        "tags": [
          "ffl_integrations"
        ],
        "summary": "Live qty/price second-confirm before a Draft order is placed.",
        "description": "Open read (no only_for) by design — see ``search``; the console depends on it\nand the counter uses it. Do not add a gate.\n\n**Auth (derived from code):** Any authenticated user — no explicit role gate at function entry (deliberate open reads document this in Permissions).\n\n**Permissions:** Open by design — any authenticated desk user; see `search`.\n\nSource: `apps/ffl_integrations/ffl_integrations/distributor/api.py:316`",
        "operationId": "ffl_integrations.distributor.api.check_availability",
        "responses": {
          "200": {
            "description": "Provider availability rows (live qty/price per line).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "array"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "lines": {
                    "description": "[{sku, qty}] — list or JSON string."
                  },
                  "distributor": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "description": "Optional Distributor name."
                  }
                },
                "required": [
                  "lines"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_integrations.distributor.api.confirm_order": {
      "post": {
        "tags": [
          "ffl_integrations"
        ],
        "summary": "Confirm a Draft Distributor Order: Draft → Queued + enqueue placement.",
        "description": "Human confirmation (the v1 queue gate); the placement worker is\nidempotent. A counter-sourced drop-ship DO must be fully paid first\n(placement_payment_block); a ship-to-store leg may be placed on a deposit.\nA web order's DO is refused once the Woo order is no longer paid.\n\n**Auth (derived from code):** Roles: Purchase Manager / Purchase User / Stock Manager / System Manager / Distributor Console\n\n**Permissions:** Distributor order/console roles.\n\nSource: `apps/ffl_integrations/ffl_integrations/distributor/api.py:1093`",
        "operationId": "ffl_integrations.distributor.api.confirm_order",
        "responses": {
          "200": {
            "description": "{\"name\": ..., \"status\": \"Queued\"}.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "do_name": {
                    "type": "string",
                    "description": "Distributor Order name."
                  }
                },
                "required": [
                  "do_name"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_integrations.distributor.api.create_orders": {
      "post": {
        "tags": [
          "ffl_integrations"
        ],
        "summary": "Plan + create the Draft Distributor Order(s) for a cart.",
        "description": "`plan_fulfillment` may split one cart into several orders (no\nfirearm/accessory mixing / H4 >400) — each becomes its own Draft DO. A\nclassification divergence raises (order held for a human). Never\nplaces anything: v1 is a human-confirmed queue.\n\n**Auth (derived from code):** Roles: Purchase Manager / Purchase User / Stock Manager / System Manager\n\n**Permissions:** Distributor order roles.\n\nSource: `apps/ffl_integrations/ffl_integrations/distributor/api.py:778`",
        "operationId": "ffl_integrations.distributor.api.create_orders",
        "responses": {
          "200": {
            "description": "[{name, order_type, account, line_count}] — one per created Draft DO.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "array"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "distributor": {
                    "type": "string",
                    "description": "Distributor name."
                  },
                  "lines": {
                    "description": "Cart lines [{sku/item_code, qty, ...}] — list or JSON string."
                  },
                  "ship_context": {
                    "description": "Optional {mode: \"stocking\"|\"to_store\"|\"direct\"|\"fds\", ...} — the lane to order on (see distributor/lanes.py); defaults to stocking."
                  }
                },
                "required": [
                  "distributor",
                  "lines"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_integrations.distributor.api.ensure_dropship_item": {
      "post": {
        "tags": [
          "ffl_integrations"
        ],
        "summary": "Counter Create Order seam: make sure this catalog SKU has a local Item that",
        "description": "can carry a drop-ship line — dual-source guard → idempotent promote →\n``dropship_distributor`` stamp — WITHOUT a web listing (that stays Flow B's\n``create_listing``). Closes the gap where an un-promoted SKU produced a\ncounter line with no item_code that ``_validate_items`` then refused.\n\nA WRITE (Item insert + stamp), so unlike search/quote it is role-gated — to\nthe same roles that may ring the counter order itself (manual_order._ROLES).\nAn Item already stamped by ANOTHER distributor is returned as it is, never\nre-homed: the counter line orders from the house it names, while the stamp\nkeeps driving the web listing, web-order routing and stock publishing.\n\n**Auth (derived from code):** Roles: Sales User / Sales Manager / Stock Manager / System Manager\n\n**Permissions:** Counter roles (Sales User / Sales Manager / Stock Manager / System Manager).\n\nSource: `apps/ffl_integrations/ffl_integrations/distributor/api.py:485`",
        "operationId": "ffl_integrations.distributor.api.ensure_dropship_item",
        "responses": {
          "200": {
            "description": "{item_code, item_name, is_firearm, claimed_by} — claimed_by is the house the Item's drop-ship stamp names after the call (empty when nothing claims it).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "sku": {
                    "type": "string",
                    "description": "Distributor SKU (required)."
                  },
                  "distributor": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "description": "Optional Distributor name; defaults to the resolved primary."
                  },
                  "claim": {
                    "description": "1 (default) stamps the Item's ``dropship_distributor`` for this house when it has none and no listing holds it (a listed product's stamp is its listing's); 0 only promotes it — a ship-to-store line buys the goods into our own stock and says nothing about who drop-ships the Item on the web.",
                    "default": 1
                  }
                },
                "required": [
                  "sku"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_integrations.distributor.api.fulfillment_freight": {
      "post": {
        "tags": [
          "ffl_integrations"
        ],
        "summary": "Estimated distributor freight for the Fulfillment planner's CURRENT choice.",
        "description": "The planner re-asks on every selection change. Lines are grouped exactly as\nthe counter hook will order them — by (distributor, lane) and then the\nprovider's own split (firearms and accessories never share an order) — and\neach resulting order is priced by the provider's freight rules, so a mixed\ndrop-ship + ship-to-store cart is the sum of its real orders. Nothing is\nread from the catalog: the matrix already sent cost / department /\nffl_required, and this is a display estimate (the invoiced freight wins).\n\n**Auth (derived from code):** Roles: Sales User / Sales Manager / Stock Manager / System Manager\n\n**Permissions:** Counter roles — the planner belongs to Create Order.\n\nSource: `apps/ffl_integrations/ffl_integrations/distributor/api.py:741`",
        "operationId": "ffl_integrations.distributor.api.fulfillment_freight",
        "responses": {
          "200": {
            "description": "{\"orders\": [{distributor, mode, order_type, line_count, merchandise, freight, firearm, options_key, options}], \"total\": float, \"complete\": bool} — freight is None (and complete False) for a house that can't estimate; options is None for a house with no delivery options to choose.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "lines": {
                    "description": "[{distributor, mode: \"direct\"|\"to_store\", sku, item_code?, qty, cost, department, ffl_required}] — list or JSON string; local lines are simply not sent."
                  },
                  "options": {
                    "description": "Optional {options_key: {signature, adult_signature, insurance}} — the delivery options picked per order (list or JSON string); an order without an entry uses its house's defaults."
                  }
                },
                "required": [
                  "lines"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_integrations.distributor.api.fulfillment_matrix": {
      "post": {
        "tags": [
          "ffl_integrations"
        ],
        "summary": "One-shot batch quote for the Create Order Fulfillment planner.",
        "description": "Every line × (local stock + each\nenabled distributor). Open read (like search/quote). Column-level\ndegradation — one failing house only greys out its own column; the\nlocal column and the rest render normally.\n\n**Auth (derived from code):** Any authenticated user — no explicit role gate at function entry (deliberate open reads document this in Permissions).\n\n**Permissions:** Open by design — any authenticated desk user; see `search`.\n\nSource: `apps/ffl_integrations/ffl_integrations/distributor/api.py:567`",
        "operationId": "ffl_integrations.distributor.api.fulfillment_matrix",
        "responses": {
          "200": {
            "description": "{\"columns\": [distributor, ...], \"rows\": [{item_code, sku, qty, local: {in_stock, feasible}, is_firearm, channels: [cell, ...], preselect, preselect_mode}]} — is_firearm is what the server enforces for the line's own Item (None without one); cell = {distributor, sku, cost, store_cost (the per-unit cost shipped to the store: full cases at the house's case price), case_note? (the case-price hint), qty, department, mode: \"direct\"|\"to_store\" (the house's default), modes: {direct, to_store: {feasible, reason}}, ffl_required, feasible, reason?} or {distributor, error: True}.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "lines": {
                    "description": "[{\"item_code\": str?, \"sku\": str?, \"upc\": str?, \"qty\": int}] — list or JSON string. A line with only ``upc`` (an \"API\" pick whose house is not chosen yet) resolves per column by UPC."
                  }
                },
                "required": [
                  "lines"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_integrations.distributor.api.list_orders": {
      "post": {
        "tags": [
          "ffl_integrations"
        ],
        "summary": "List Distributor Orders, newest-modified first — every house and every",
        "description": "order type in one list (the Distributor Orders page's tracking tab).\n\n**Auth (derived from code):** Roles: Purchase Manager / Purchase User / Stock Manager / System Manager\n\nSource: `apps/ffl_integrations/ffl_integrations/distributor/api.py:1194`",
        "operationId": "ffl_integrations.distributor.api.list_orders",
        "responses": {
          "200": {
            "description": "[{name, distributor, order_type, account, account_number, status, hold_status, web_ref, total_cost, placed_at, next_poll_at, receive_status, source_doctype, source_name, creation, last_poll_at, invoiced_freight, error}] — plus ``lines`` when asked.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "array"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "status": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "description": "Optional exact status filter."
                  },
                  "distributor": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "description": "Optional Distributor filter."
                  },
                  "limit": {
                    "type": "integer",
                    "description": "Row cap (default 50, max 500).",
                    "default": 50
                  },
                  "open_only": {
                    "description": "1 = leave out Complete and Cancelled orders.",
                    "default": 0
                  },
                  "order_type": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "description": "Optional exact order type (Stocking, Dropship Firearm, ...)."
                  },
                  "with_lines": {
                    "description": "1 = add each order's ``lines`` [{sku, description, wish_qty, invoiced_qty, received_qty, line_status, tracking_numbers, invoices}].",
                    "default": 0
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_integrations.distributor.api.quote": {
      "post": {
        "tags": [
          "ffl_integrations"
        ],
        "summary": "Per-item drop-ship quote for the Create Order panel and the counter",
        "description": "server-side eligibility check.\n\n       ``fulfillment_mode`` is the RESOLVED judgement (Direct / To Store)\n       through the canonical chain — consumers judging drop-shippability read IT,\n       not the raw flags. ``restricted_states`` = states where the distributor's\n       own restriction feed blocks drop-ship of this SKU — display only, and\n       NOT the operator's ``Item.restricted_states`` compliance field.\n       ``suggested_price`` is the SAME chain the listing\n       pipeline prices with (``listing_price.price_for``) — never a second pricing path —\n       as the COUNTER price: the website's MAP floor does not apply at the counter\nso it can sit below the listing's website price. Reads the\n       provider's LOCAL catalog (no HTTP), so it is cheap enough per keystroke; the\n       real-time RSR re-confirm stays at placement (``place_order_job``).\n\n       A read — open to any signed-in desk user (like ``search`` / ``check_availability``).\n       This openness is load-bearing: it is WHY the counter register can quote without\n       the console role. Do not add only_for here (the one effect is to break\n       Create Order, with no security gain since catalog data has no PII).\n\n**Auth (derived from code):** Any authenticated user — no explicit role gate at function entry (deliberate open reads document this in Permissions).\n\n**Permissions:** Open by design — any authenticated desk user; catalog data carries no PII and the counter panel depends on it.\n\nSource: `apps/ffl_integrations/ffl_integrations/distributor/api.py:339`",
        "operationId": "ffl_integrations.distributor.api.quote",
        "responses": {
          "200": {
            "description": "{found, sku, upc, item_code, distributor, cost, map, msrp, suggested_price, qty, restricted_states, fulfillment_mode, dropship_blocked, vendor_approval_required, ffl_required, manufacturer, model, department} — or {found: False, ...} when not in catalog. A site with no distributor catalog answers HTTP 417 (CapabilityOff).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "item_code": {
                    "description": "Local Item code (resolves the distributor stamp when `distributor` is omitted)."
                  },
                  "sku": {
                    "description": "Distributor SKU (either this or item_code must resolve)."
                  },
                  "distributor": {
                    "description": "Optional Distributor name."
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_integrations.distributor.api.search": {
      "post": {
        "tags": [
          "ffl_integrations"
        ],
        "summary": "Typeahead over the resolved provider's catalog (RSR reuses rsr/search.py).",
        "description": "Open read, no only_for: catalog-level data carries no PII, and the console role\ndepends on this openness. Do NOT add a gate here — the only effect would\nbe to break the counter Create Order panel, with no security gain.\n\nClamped to the service contract (`CatalogSearchRequest`: `q` min_length=1,\n`limit` 1..50) — same shape as rsr/search.py's shim — so an empty/blank query\nor an out-of-range limit never reaches the transport at all.\n\n**Auth (derived from code):** Any authenticated user — no explicit role gate at function entry (deliberate open reads document this in Permissions).\n\n**Permissions:** Open read for any signed-in desk user (load-bearing, see above).\n\nSource: `apps/ffl_integrations/ffl_integrations/distributor/api.py:187`",
        "operationId": "ffl_integrations.distributor.api.search",
        "responses": {
          "200": {
            "description": "Catalog rows, each tagged with its `distributor` provenance.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "array"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "query": {
                    "type": "string",
                    "description": "Search term (blank returns [])."
                  },
                  "limit": {
                    "type": "integer",
                    "description": "Row cap, clamped to 1–50 (default 10).",
                    "default": 10
                  },
                  "distributor": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "description": "Optional Distributor name; defaults to the resolved primary."
                  }
                },
                "required": [
                  "query"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_integrations.distributor.api.set_shipping_service": {
      "post": {
        "tags": [
          "ffl_integrations"
        ],
        "summary": "Choose the carrier service for a Draft Distributor Order.",
        "description": "Only a Draft order may change (Queued and later are at or past the\ndistributor); the code must be one the provider offers for this order.\n\n**Auth (derived from code):** Roles: Purchase Manager / Purchase User / Stock Manager / System Manager / Distributor Console\n\n**Permissions:** Distributor order/console roles.\n\nSource: `apps/ffl_integrations/ffl_integrations/distributor/api.py:1012`",
        "operationId": "ffl_integrations.distributor.api.set_shipping_service",
        "responses": {
          "200": {
            "description": "{\"name\", \"shipping_service\", \"shipping_service_label\"}.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "do_name": {
                    "type": "string",
                    "description": "Distributor Order name."
                  },
                  "code": {
                    "type": "string",
                    "description": "Service code from ``shipping_options`` ('' = the provider's empty-code service, e.g. Sports South Ground Economy)."
                  }
                },
                "required": [
                  "do_name",
                  "code"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_integrations.distributor.api.shipping_options": {
      "post": {
        "tags": [
          "ffl_integrations"
        ],
        "summary": "Carrier services the distributor offers for this order, with the",
        "description": "flat-rate estimate, so the operator can choose before Confirm.\n\n**Auth (derived from code):** Roles: Purchase Manager / Purchase User / Stock Manager / System Manager / Distributor Console\n\n**Permissions:** Distributor order/console roles.\n\nSource: `apps/ffl_integrations/ffl_integrations/distributor/api.py:987`",
        "operationId": "ffl_integrations.distributor.api.shipping_options",
        "responses": {
          "200": {
            "description": "[{code, label, estimate, default, selected}] — empty when the provider decides shipping itself.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "array"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "do_name": {
                    "type": "string",
                    "description": "Distributor Order name."
                  }
                },
                "required": [
                  "do_name"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_integrations.distributor.api.transition_order": {
      "post": {
        "tags": [
          "ffl_integrations"
        ],
        "summary": "Generic ops state transition for a Distributor Order.",
        "description": "The DO state machine still enforces transition legality.\n\n**Auth (derived from code):** Roles: Purchase Manager / Purchase User / Stock Manager / System Manager\n\n**Permissions:** Distributor order roles.\n\nSource: `apps/ffl_integrations/ffl_integrations/distributor/api.py:1171`",
        "operationId": "ffl_integrations.distributor.api.transition_order",
        "responses": {
          "200": {
            "description": "{\"name\": ..., \"status\": <new status>}.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "do_name": {
                    "type": "string",
                    "description": "Distributor Order name."
                  },
                  "to_status": {
                    "type": "string",
                    "description": "Target status."
                  }
                },
                "required": [
                  "do_name",
                  "to_status"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_integrations.distributor.hub.overview": {
      "post": {
        "tags": [
          "ffl_integrations"
        ],
        "summary": "Everything the distributor-hub page renders, in one round trip.",
        "description": "Heartbeats are guarded per provider — a dead catalog service greys that\nprovider's health line instead of blanking the page.\n\n**Auth (derived from code):** Roles: System Manager / Purchase Manager / Purchase User / Stock Manager\n\n**Permissions:** Hub read roles.\n\nSource: `apps/ffl_integrations/ffl_integrations/distributor/hub.py:41`",
        "operationId": "ffl_integrations.distributor.hub.overview",
        "responses": {
          "200": {
            "description": "{distributors: [per-house rows with flags/priority/health and summary: [{label, value, tab}]], providers: [{code, settings_doctype, used_by}], can_write, catalog_local: {local, worker_running, warning}, can_sync_now (Local catalog and System Manager), capabilities: {catalog} (the data_service capability the page shows)}, and per row catalog_lanes (Local catalog only, else null): {lanes: [{lane, last_success_at, rows, last_status, error_class}], offers_total, offers_active}. A house whose catalog reads are off (its own service, else the site's) has health {catalog_off: true} instead of a probe.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        }
      }
    },
    "/api/method/ffl_integrations.distributor.hub.reorder": {
      "post": {
        "tags": [
          "ffl_integrations"
        ],
        "summary": "Persist a FULL permutation of distributor names as priorities 1..N.",
        "description": "Partial lists are rejected — a missing row would silently keep a stale\npriority that may collide with the new ones.\n\n**Auth (derived from code):** Roles: System Manager / Purchase Manager\n\n**Permissions:** Hub write roles.\n\nSource: `apps/ffl_integrations/ffl_integrations/distributor/hub.py:193`",
        "operationId": "ffl_integrations.distributor.hub.reorder",
        "responses": {
          "200": {
            "description": "{\"order\": names}.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "names": {
                    "description": "Every Distributor name exactly once, in the new order — list or JSON string."
                  }
                },
                "required": [
                  "names"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_integrations.distributor.hub.sync_now": {
      "post": {
        "tags": [
          "ffl_integrations"
        ],
        "summary": "Queue every lane of one house's local catalog now (the hub's Sync now).",
        "description": "Each lane's schedule is skipped; no guard is: a short, truncated or shrunk\nfeed file is refused as on a scheduled run.\n\n**Auth (derived from code):** Roles: System Manager\n\nSource: `apps/ffl_integrations/ffl_integrations/distributor/hub.py:248`",
        "operationId": "ffl_integrations.distributor.hub.sync_now",
        "responses": {
          "200": {
            "description": "{enqueued: [lane sources], deduplicated: [lane sources already queued or running], worker_running}.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "distributor": {
                    "type": "string",
                    "description": "Distributor name."
                  }
                },
                "required": [
                  "distributor"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_integrations.distributor.hub.test_connection": {
      "post": {
        "tags": [
          "ffl_integrations"
        ],
        "summary": "Run the provider's live connection probe for one distributor.",
        "description": "Read-role gated: it is a diagnostic with no order-side effects\n(providers keep probes read-only).\n\n**Auth (derived from code):** Roles: System Manager / Purchase Manager / Purchase User / Stock Manager\n\n**Permissions:** Hub read roles.\n\nSource: `apps/ffl_integrations/ffl_integrations/distributor/hub.py:225`",
        "operationId": "ffl_integrations.distributor.hub.test_connection",
        "responses": {
          "200": {
            "description": "The provider's connection_test() result.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "distributor": {
                    "type": "string",
                    "description": "Distributor name."
                  }
                },
                "required": [
                  "distributor"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_integrations.distributor.hub.toggle_flag": {
      "post": {
        "tags": [
          "ffl_integrations"
        ],
        "summary": "Flip one routing flag on one distributor.",
        "description": "Doc-level write permission enforced on top of the role gate (a Purchase\nManager without a doc share still passes — doctype perms grant write —\nbut User Permissions are honoured).\n\n**Auth (derived from code):** Roles: System Manager / Purchase Manager\n\n**Permissions:** Hub write roles + doc-level write check.\n\nSource: `apps/ffl_integrations/ffl_integrations/distributor/hub.py:165`",
        "operationId": "ffl_integrations.distributor.hub.toggle_flag",
        "responses": {
          "200": {
            "description": "{name, flag, value: 0|1}.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "distributor": {
                    "type": "string",
                    "description": "Distributor name."
                  },
                  "flag": {
                    "type": "string",
                    "description": "One of the hub's togglable flags (others are refused)."
                  },
                  "value": {
                    "description": "Truthy/falsy."
                  }
                },
                "required": [
                  "distributor",
                  "flag",
                  "value"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_integrations.distributor.invoices.list_invoices": {
      "post": {
        "tags": [
          "ffl_integrations"
        ],
        "summary": "Mirrored distributor invoices, newest first, with their lines.",
        "description": "**Auth (derived from code):** Roles: Purchase Manager / Purchase User / Stock Manager / System Manager\n\n**Permissions:** Distributor order roles.\n\nSource: `apps/ffl_integrations/ffl_integrations/distributor/invoices.py:328`",
        "operationId": "ffl_integrations.distributor.invoices.list_invoices",
        "responses": {
          "200": {
            "description": "[{name, distributor, invoice_number, invoice_date, account, po_number, order_ref, distributor_order, outside_pos, destination, received, likely_order, total, freight, fees, tracking_numbers, lines: [{sku, description, qty, unit_cost, amount, tracking_number, serials, upc, item_code, received_qty}]}]. ``likely_order``: for an unreceived Store invoice no order is linked to, the open store-bound POS order that probably is this parcel (awaiting the status poll's link), else \"\".",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "array"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "distributor": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "description": "Optional Distributor filter."
                  },
                  "outside_pos": {
                    "description": "1 = only invoices no POS order matches.",
                    "default": 0
                  },
                  "limit": {
                    "type": "integer",
                    "description": "Row cap (default 100, max 500).",
                    "default": 100
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_integrations.distributor.invoices.outside_open_orders": {
      "post": {
        "tags": [
          "ffl_integrations"
        ],
        "summary": "Orders on a house's account that were NOT placed from this POS and are not",
        "description": "invoiced yet, from the order headers the hourly sync cached (houses whose\nprovider can list orders; no live distributor call here). Only orders dated\ninside the invoice mirror's window are judged: an older order's invoice may\npredate the mirror, so \"no invoice on file\" would not mean \"not invoiced\".\n\n**Auth (derived from code):** Roles: Purchase Manager / Purchase User / Stock Manager / System Manager\n\n**Permissions:** Distributor order roles.\n\nSource: `apps/ffl_integrations/ffl_integrations/distributor/invoices.py:379`",
        "operationId": "ffl_integrations.distributor.invoices.outside_open_orders",
        "responses": {
          "200": {
            "description": "[{distributor, order_ref, po_number, order_date, status}].",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "array"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        }
      }
    },
    "/api/method/ffl_integrations.distributor.invoices.sync_invoices_now": {
      "post": {
        "tags": [
          "ffl_integrations"
        ],
        "summary": "Queue a pull of every house's recent invoices now (the hourly job, on",
        "description": "demand). Runs on the worker; a pull already queued or running is not doubled.\n\n**Auth (derived from code):** Roles: Purchase Manager / Purchase User / Stock Manager / System Manager\n\n**Permissions:** Distributor order roles.\n\nSource: `apps/ffl_integrations/ffl_integrations/distributor/invoices.py:312`",
        "operationId": "ffl_integrations.distributor.invoices.sync_invoices_now",
        "responses": {
          "200": {
            "description": "{queued: True}.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        }
      }
    },
    "/api/method/ffl_integrations.distributor.price_hub.detail": {
      "post": {
        "tags": [
          "ffl_integrations"
        ],
        "summary": "One product's cost history and this store's own record of it.",
        "description": "**Auth (derived from code):** Roles: Purchase Manager / Purchase User / Stock Manager / System Manager\n\nSource: `apps/ffl_integrations/ffl_integrations/distributor/price_hub.py:34`",
        "operationId": "ffl_integrations.distributor.price_hub.detail",
        "responses": {
          "200": {
            "description": "{trend: {days, window_start, server_time, series: [{distributor, sku, state, segments: [[{at, cost}]], last_cost, low_cost, high_cost}]} or null (no history, or the service is down), store: {item_code, on_hand, on_order, sold_30, sold_90, price, receipts: [{posting_date, supplier, qty, rate}]} or null (no Item here)}. Only enabled Distributors the site-wide catalog serves have a series (not one on its own catalog service). ``trend.days`` is the window read: a year when everything kept was asked for and is too much to return.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "upc": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "description": "The product's UPC."
                  },
                  "sku": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "description": "A distributor SKU — names the product when it has no UPC."
                  },
                  "distributor": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "description": "The Distributor that SKU belongs to."
                  },
                  "days": {
                    "type": "integer",
                    "description": "History window in days; 0 is everything the service keeps.",
                    "default": 90
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_integrations.distributor.price_hub.signals": {
      "post": {
        "tags": [
          "ffl_integrations"
        ],
        "summary": "What the enabled distributors' feeds showed lately: costs that fell, stock",
        "description": "about to run out, and stock that went fast after a restock.\n\n**Auth (derived from code):** Roles: Purchase Manager / Purchase User / Stock Manager / System Manager\n\nSource: `apps/ffl_integrations/ffl_integrations/distributor/price_hub.py:62`",
        "operationId": "ffl_integrations.distributor.price_hub.signals",
        "responses": {
          "200": {
            "description": "{cost_drop, stockout, fast_depletion}: each a list of {distributor, sku, upc, name, current_value, reference_value, amount, score}, the strongest first. cost_drop: the cost now and before, the fall in dollars and percent. stockout: units left, and score the days of cover. fast_depletion: units left, units gone, and the percent gone. Observations of the feed, not sales. Empty lists when the service keeps no history or is down.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "days": {
                    "type": "integer",
                    "description": "Window in days, 1 to 30.",
                    "default": 7
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_integrations.distributor.receive_bridge.build_receive_payload": {
      "post": {
        "tags": [
          "ffl_integrations"
        ],
        "summary": "Pre-fill the Receive Goods page from a Distributor Order (read-only).",
        "description": "DIVERGENCE-3: reads the DO, enriches lines from their Item, computes\nthis batch's receivable increment, and guards firearm serial counts —\nbut does NOT submit anything.\n\n**Auth (derived from code):** Roles: Stock Manager / System Manager\n\n**Permissions:** Receive roles.\n\nSource: `apps/ffl_integrations/ffl_integrations/distributor/receive_bridge.py:470`",
        "operationId": "ffl_integrations.distributor.receive_bridge.build_receive_payload",
        "responses": {
          "200": {
            "description": "A create_receive-shaped payload pre-filled from the DO.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "do_name": {
                    "type": "string",
                    "description": "Distributor Order name."
                  }
                },
                "required": [
                  "do_name"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_integrations.distributor.receive_bridge.list_incoming": {
      "post": {
        "tags": [
          "ffl_integrations"
        ],
        "summary": "Every store-bound Distributor Order with units still outstanding, grouped",
        "description": "by the customer order it serves (restock last), for the Receive Goods\n\"Incoming shipments\" panel.\n\nEach order carries what the house said it is sending, what we booked, the\ntracking numbers the poll saw, and its lines with per-line outstanding units\nand the serials the house echoed — enough to load a whole customer order or\none parcel into the receive session and tick units off as they are scanned.\nRestock also lists the outside-POS store invoices (a parcel ordered off-system:\n``do_name`` blank, ``invoice_name`` set, ``lines`` empty until ``stage_invoice``).\n\n**Auth (derived from code):** Roles: Stock Manager / System Manager\n\n**Permissions:** Receive roles.\n\nSource: `apps/ffl_integrations/ffl_integrations/distributor/receive_bridge.py:399`",
        "operationId": "ffl_integrations.distributor.receive_bridge.list_incoming",
        "responses": {
          "200": {
            "description": "{groups: [{source_doctype, source_name, customer_name, label, orders: [{do_name, invoice_name, invoice_number, outside_pos, distributor, supplier, customer_name, status, hold_status, web_ref, placed_at, source_doctype, source_name, tracking_numbers, expected, received, outstanding, lines: [{line_name, item_code, item_name, sku, is_firearm, outstanding, unit_cost, serials}]}]}]}.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        }
      }
    },
    "/api/method/ffl_integrations.distributor.receive_bridge.match_incoming": {
      "post": {
        "tags": [
          "ffl_integrations"
        ],
        "summary": "Open store-bound Distributor Order lines a scanned unit of this item could",
        "description": "belong to, earliest order first.\n\nThe Receive Goods page asks this on every UPC scan: one candidate opens the\n\"hold it for this order?\" prompt, several list them, none means plain\nrestock. Only lines with units still outstanding (``outstanding_qty``) are\nreturned, so a line already received or covered from shelf stock never\nclaims a parcel.\n\n**Auth (derived from code):** Roles: Stock Manager / System Manager\n\n**Permissions:** Receive roles.\n\nSource: `apps/ffl_integrations/ffl_integrations/distributor/receive_bridge.py:355`",
        "operationId": "ffl_integrations.distributor.receive_bridge.match_incoming",
        "responses": {
          "200": {
            "description": "{item_code, candidates: [{do_name, line_name, distributor, supplier, order_type, source_doctype, source_name, customer_name, outstanding, unit_cost, serials, package_index, placed_at}]}.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "item_code": {
                    "type": "string",
                    "description": "Item code the barcode resolved to."
                  }
                },
                "required": [
                  "item_code"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_integrations.distributor.receive_bridge.receive_from_do": {
      "post": {
        "tags": [
          "ffl_integrations"
        ],
        "summary": "Receive a Distributor Order: create + submit the Purchase Receipt.",
        "description": "Staff action from the pre-filled Receive Goods page: creates + submits\nthe Purchase Receipt (fires the FastBound acquisition push — with the\nDO stamped onto each acquisition BEFORE the push via the payload's\n`distributor_order` key, M2), bumps received_qty per line on the DO,\nadvances receive_status, and idempotently backstops the\nDO→acquisition link.\n\n**Auth (derived from code):** Roles: Stock Manager / System Manager\n\n**Permissions:** Receive roles.\n\nSource: `apps/ffl_integrations/ffl_integrations/distributor/receive_bridge.py:493`",
        "operationId": "ffl_integrations.distributor.receive_bridge.receive_from_do",
        "responses": {
          "200": {
            "description": "The receive result (Purchase Receipt name + updated DO state).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "do_name": {
                    "type": "string",
                    "description": "Distributor Order name."
                  },
                  "payload": {
                    "description": "Optional edited create_receive payload; defaults to the freshly built pre-fill — dict or JSON string."
                  }
                },
                "required": [
                  "do_name"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_integrations.distributor.receive_bridge.receive_invoice_lines": {
      "post": {
        "tags": [
          "ffl_integrations"
        ],
        "summary": "Receive units of an outside-POS store invoice into stock and the A&D book —",
        "description": "``receive_lines`` for a parcel that has no Distributor Order.\n\nThe Receive Goods page submits one call per staged invoice. Each item names the\ninvoice line, the units and (for a firearm) the serial(s) read off the gun. Cost\nis the invoiced unit cost unless the receiver changed it; a $0 line must say why,\nexactly as on the page. A line cannot be received beyond its invoiced quantity\nless what earlier receives booked, and the invoice is marked received when every\nline is in. Booked against the Distributor's Supplier, Purchase, source = the\nhouse; the receipt's remarks name the invoice. Refused for an invoice that\nalready shipped elsewhere, was received, that a POS order now claims, or that\nlooks like the parcel of an open POS order.\n\n**Auth (derived from code):** Roles: Stock Manager / System Manager\n\n**Permissions:** Receive roles.\n\nSource: `apps/ffl_integrations/ffl_integrations/distributor/receive_bridge.py:938`",
        "operationId": "ffl_integrations.distributor.receive_bridge.receive_invoice_lines",
        "responses": {
          "200": {
            "description": "create_receive's result ({ok, name, total}) plus ``invoice_name`` and ``received`` (True once every line is booked).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "invoice_name": {
                    "type": "string",
                    "description": "Distributor Invoice name."
                  },
                  "items": {
                    "description": "[{line_name, qty, serials?, rate?, manufacturer?, model_name?, firearm_type?, caliber?, importer?, service_need?, sell_price?, is_antique?, year_made?, zero_cost_*?}] — list or JSON string."
                  },
                  "warehouse": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "description": "Optional target warehouse (defaults like create_receive)."
                  }
                },
                "required": [
                  "invoice_name",
                  "items"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_integrations.distributor.receive_bridge.receive_lines": {
      "post": {
        "tags": [
          "ffl_integrations"
        ],
        "summary": "Receive SOME units of a Distributor Order — the ones a receiver just",
        "description": "scanned — into stock and the A&D book, and hold them for the waiting order.\n\nThe scan-first Receive Goods page submits one call per order it touched.\nEach item names the order line, the units, and (for a firearm) the serial(s)\nthe receiver read off the gun — the distributor's echoed serial is a hint on\nscreen, never what gets booked. Cost is the line's invoiced unit cost when the\npoll has it, else the order-line cost; a $0 line must say why, exactly as on\nthe page. Over-receiving a line (more than ``outstanding_qty``) is refused.\n\n**Auth (derived from code):** Roles: Stock Manager / System Manager\n\n**Permissions:** Receive roles.\n\nSource: `apps/ffl_integrations/ffl_integrations/distributor/receive_bridge.py:575`",
        "operationId": "ffl_integrations.distributor.receive_bridge.receive_lines",
        "responses": {
          "200": {
            "description": "create_receive's result ({ok, name, total}) plus ``do_name``.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "do_name": {
                    "type": "string",
                    "description": "Distributor Order name."
                  },
                  "items": {
                    "description": "[{line_name, qty, serials?, rate?, manufacturer?, model_name?, firearm_type?, caliber?, importer?, service_need?, zero_cost_*?}] — list or JSON string."
                  },
                  "warehouse": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "description": "Optional target warehouse (defaults like create_receive)."
                  }
                },
                "required": [
                  "do_name",
                  "items"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_integrations.distributor.receive_bridge.stage_invoice": {
      "post": {
        "tags": [
          "ffl_integrations"
        ],
        "summary": "Lay an outside-POS store invoice out for the Receive Goods page: each line's",
        "description": "local Item (found in the house's catalog by SKU, else UPC, and created through the\ncatalog promoter when the shop has none; an existing local Item when the catalog\nhas no row), the units still to book, the invoiced unit cost and — for a\nfirearm — the serials the distributor sent that are not in the books yet.\n\n**Auth (derived from code):** Roles: Stock Manager / System Manager\n\n**Permissions:** Receive roles.\n\nSource: `apps/ffl_integrations/ffl_integrations/distributor/receive_bridge.py:870`",
        "operationId": "ffl_integrations.distributor.receive_bridge.stage_invoice",
        "responses": {
          "200": {
            "description": "{invoice_name, invoice_number, distributor, unmatched: [{sku, reason}], lines: [{line_name, item_code, item_name, sku, is_firearm, has_serial_no, outstanding, unit_cost, serials, manufacturer, model_name, firearm_type, caliber}], received} — ``unmatched`` lists lines no Item could be found or made for (left off ``lines``; receive those as plain stock). ``received``: true when the only units left were $0 unmatched lines (a promo freebie), so the invoice was closed here.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "invoice_name": {
                    "type": "string",
                    "description": "Distributor Invoice name."
                  }
                },
                "required": [
                  "invoice_name"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_integrations.distributor.router.precheck_fds": {
      "post": {
        "tags": [
          "ffl_integrations"
        ],
        "summary": "Pre-check whether the transfer dealer accepts FDS shipments.",
        "description": "Asked of the distributor BEFORE the order is placed — the cheapest way\nto avoid an FDS Hold.\n\n**Auth (derived from code):** Roles: Purchase Manager / Purchase User / Stock Manager / System Manager\n\n**Permissions:** Distributor API roles.\n\nSource: `apps/ffl_integrations/ffl_integrations/distributor/router.py:449`",
        "operationId": "ffl_integrations.distributor.router.precheck_fds",
        "responses": {
          "200": {
            "description": "{\"supported\": False} when the provider can't verify dealers, else {\"supported\": True, \"result\": <provider verification>}.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "do_name": {
                    "type": "string",
                    "description": "Distributor Order name (carries the transfer FFL)."
                  }
                },
                "required": [
                  "do_name"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_integrations.distributor.router.update_order_ffl": {
      "post": {
        "tags": [
          "ffl_integrations"
        ],
        "summary": "Attach/replace the transfer FFL on a placed FDS order to release an FDS Hold",
        "description": "(the standard remedy the completion path calls for).\n\nRe-validates the NEW licence through the SAME canonical chain routing uses\nBEFORE calling the distributor: releasing a hold onto an expired or\naddress-incomplete FFL would defeat the very gate that held it, on a channel\nwith no cancel API. The resolved ATF record is pinned so the queue's expiry\ndisplay and any later disposition read one destination.\n\n**Auth (derived from code):** Roles: Purchase Manager / Purchase User / Stock Manager / System Manager / Distributor Console\n\n**Permissions:** Distributor order/console roles (this gate is deliberately widened to the console role).\n\nSource: `apps/ffl_integrations/ffl_integrations/distributor/router.py:489`",
        "operationId": "ffl_integrations.distributor.router.update_order_ffl",
        "responses": {
          "200": {
            "description": "{\"name\": do_name, \"ffl\": ffl_license, \"result\": <distributor response>}.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "do_name": {
                    "type": "string",
                    "description": "Distributor Order name (a placed FDS order on hold)."
                  },
                  "ffl_license": {
                    "type": "string",
                    "description": "The new transfer FFL licence number."
                  }
                },
                "required": [
                  "do_name",
                  "ffl_license"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_integrations.distributor.tasks.poll_order_now": {
      "post": {
        "tags": [
          "ffl_integrations"
        ],
        "summary": "Pull one Distributor Order's status from the house right now — the",
        "description": "\"Check status now\" button, for a parcel that beat the 30-minute poll.\n\nRuns the same ``poll_order`` the scheduler runs (schedule advances as\nusual); a non-pollable order (Draft, Complete, Cancelled…) is left alone.\n\n**Auth (derived from code):** Roles: Stock Manager / System Manager\n\n**Permissions:** Receive roles.\n\nSource: `apps/ffl_integrations/ffl_integrations/distributor/tasks.py:440`",
        "operationId": "ffl_integrations.distributor.tasks.poll_order_now",
        "responses": {
          "200": {
            "description": "{name, status, receive_status, hold_status, lines} after the poll.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "do_name": {
                    "type": "string",
                    "description": "Distributor Order name."
                  }
                },
                "required": [
                  "do_name"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_integrations.fastbound.client_api.get_acquire_types": {
      "post": {
        "tags": [
          "ffl_integrations"
        ],
        "summary": "Cached AcquireType options for the Acquisition type dropdown.",
        "description": "**Auth (derived from code):** Roles: Stock Manager / System Manager\n\nSource: `apps/ffl_integrations/ffl_integrations/fastbound/client_api.py:97`",
        "operationId": "ffl_integrations.fastbound.client_api.get_acquire_types",
        "responses": {
          "200": {
            "description": "List of type strings ([] until sync_smart_lists has run).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "array"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        }
      }
    },
    "/api/method/ffl_integrations.fastbound.client_api.get_dispose_types": {
      "post": {
        "tags": [
          "ffl_integrations"
        ],
        "summary": "Cached DisposeType options for the Disposition type dropdown.",
        "description": "**Auth (derived from code):** Roles: Stock Manager / System Manager\n\nSource: `apps/ffl_integrations/ffl_integrations/fastbound/client_api.py:108`",
        "operationId": "ffl_integrations.fastbound.client_api.get_dispose_types",
        "responses": {
          "200": {
            "description": "List of type strings ([] until sync_smart_lists has run).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "array"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        }
      }
    },
    "/api/method/ffl_integrations.fastbound.client_api.sync_smart_lists": {
      "post": {
        "tags": [
          "ffl_integrations"
        ],
        "summary": "Sync FastBound's AcquireType/DisposeType SmartLists into Settings.",
        "description": "Pulls presets + custom values and caches them on FastBound Settings\nfor the Acquisition / Disposition type dropdowns.\n\n**Auth (derived from code):** Roles: System Manager\n\nSource: `apps/ffl_integrations/ffl_integrations/fastbound/client_api.py:43`",
        "operationId": "ffl_integrations.fastbound.client_api.sync_smart_lists",
        "responses": {
          "200": {
            "description": "{\"ok\": True, \"acquire_count\": n, \"dispose_count\": n}.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        }
      }
    },
    "/api/method/ffl_integrations.fastbound.client_api.test_connection": {
      "post": {
        "tags": [
          "ffl_integrations"
        ],
        "summary": "Probe the FastBound connection via GET /Account.",
        "description": "**Auth (derived from code):** Roles: System Manager\n\nSource: `apps/ffl_integrations/ffl_integrations/fastbound/client_api.py:14`",
        "operationId": "ffl_integrations.fastbound.client_api.test_connection",
        "responses": {
          "200": {
            "description": "{\"ok\": True, \"account_name\": ..., \"raw\": <account body>} — throws a readable error when unconfigured or the API rejects.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        }
      }
    },
    "/api/method/ffl_integrations.fastbound.importer.import_bound_book": {
      "post": {
        "tags": [
          "ffl_integrations"
        ],
        "summary": "Import / re-sync the FastBound bound book into ERPNext.",
        "description": "Re-running is a SYNC: already-imported guns (matched by FastBound id) are re-synced\nfrom FastBound, which stays authoritative. A corrected maker/importer re-stamps the\nSerial No; a corrected serial renames it (stock + A&D follow); a corrected\nmodel/caliber re-keys the gun onto the right Item (reverse + re-create). Every\nstructural fix is listed in `corrected`; a gun that can't be safely auto-moved\n(sold/transferred — not a clean in-stock import) is listed in `regroup_needed`.\n\n**Auth (derived from code):** Roles: System Manager\n\nSource: `apps/ffl_integrations/ffl_integrations/fastbound/importer.py:101`",
        "operationId": "ffl_integrations.fastbound.importer.import_bound_book",
        "responses": {
          "200": {
            "description": "Import stats dict (created/synced/corrected/regroup_needed counts; plus `projected` on a dry run) and `duplicate_groups`: [{ledger_serial, no_serial, items: [{fastbound_id, itemNumber, serial, manufacturer, model, caliber}]}] — the guns that get tagged keys, to review first.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "page_size": {
                    "type": "integer",
                    "description": "FastBound page size per fetch (default 100).",
                    "default": 100
                  },
                  "dry_run": {
                    "type": "integer",
                    "description": "1 writes nothing and returns a `projected` map (item_code → count / makers / serials) to preview the grouping before committing.",
                    "default": 0
                  },
                  "commit_each": {
                    "type": "integer",
                    "description": "1 (default, production) commits after each successful item so a crash mid-import doesn't lose work; 0 (tests) relies on the caller to manage transactions.",
                    "default": 1
                  },
                  "aggregate_by": {
                    "type": "string",
                    "description": "How FB items group into ERPNext Items — \"auto\" (default): SKU → UPC → MPN → model-slug → fb_id fallback; \"model\": the model+caliber slug ONLY — SKU/UPC/MPN and manufacturer are ignored — so the same model from different manufacturers/importers (surplus M1 Garands, Mausers, …) folds into one Item; each gun's true maker + importer is stamped on its Serial No. Spelling variants are canonicalised (see fastbound.normalize)."
                  },
                  "skip_disposed": {
                    "type": "integer",
                    "description": "1 (default) imports only CURRENT INVENTORY — guns FastBound marks disposed (sold) or deleted are skipped (the importer creates acquisitions + receipts, not dispositions, so importing a sold gun would wrongly re-stock it). Pass 0 to import the entire historical book. Guns the book records with no serial (\"NONE MARKED\", \"NSN\", ...) or with the same serial as another in-stock item are each imported as their own gun under a tagged Serial No (\"<serial> (FB <item number>)\"); the serial as the book writes it is kept in Serial No.ledger_serial.",
                    "default": 1
                  },
                  "cutover_date": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "description": "The day the bound book's inventory is counted as of (default today). Each new gun posts as an opening entry on it: stock debited, the company's Temporary Opening account credited. A future, frozen or closed date is refused."
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_integrations.fastbound.importer.reassign_serial_to_item": {
      "post": {
        "tags": [
          "ffl_integrations"
        ],
        "summary": "Move one in-stock firearm serial from its current Item to `target_item`,",
        "description": "keeping the SAME Serial No and FFL Acquisition records — so the gun's price,\nphotos, condition, maker/importer/model/caliber, A&D history and FastBound\nlinkage all survive (nothing is deleted, so nothing can be dropped).\n\nERPNext ties a serial to one Item, so the stock moves with two ledger legs:\nissue the serial out of the old Item, flip the serial's item_code, then receive\nit into the target. The A&D record's `item` is re-pointed in place. FastBound is\nNOT touched — reassign is a POS-internal re-bucketing; the bound book only changes\non an explicit serial edit. A per-gun WooCommerce listing, where the gun has one,\nIS delisted: it belonged to the old Item, and leaving it live sells the same rifle\ntwice. Whitelisted for the Serial No form's \"Reassign Item\" action, for resolving\nthe sync's `regroup_needed` list, and for the Woo webhook's declared cross-Item\npick (`ffl_woo_sync.woocommerce.tasks.rebucket_and_apply_serial_task`).\n\n**Auth (derived from code):** Requires write permission on Serial No (Frappe DocType permission check).\n\nSource: `apps/ffl_integrations/ffl_integrations/fastbound/importer.py:534`",
        "operationId": "ffl_integrations.fastbound.importer.reassign_serial_to_item",
        "responses": {
          "200": {
            "description": "{ok, serial, from, to, fastbound_item_id}.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "serial": {
                    "type": "string",
                    "description": "In-stock firearm Serial No name."
                  },
                  "target_item": {
                    "type": "string",
                    "description": "Destination firearm Item code."
                  }
                },
                "required": [
                  "serial",
                  "target_item"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_integrations.fastbound.importer.start_import": {
      "post": {
        "tags": [
          "ffl_integrations"
        ],
        "summary": "Run import_bound_book in the background (a whole book outlasts a web",
        "description": "request). The result lands in FastBound Settings.last_import_result and is\nannounced with the ``fastbound_import_done`` event.\n\n**Auth (derived from code):** Roles: System Manager\n\nSource: `apps/ffl_integrations/ffl_integrations/fastbound/importer.py:229`",
        "operationId": "ffl_integrations.fastbound.importer.start_import",
        "responses": {
          "200": {
            "description": "{queued: True}.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "page_size": {
                    "type": "integer",
                    "description": "FastBound page size per fetch.",
                    "default": 100
                  },
                  "dry_run": {
                    "type": "integer",
                    "description": "1 counts and lists what would happen, writing nothing.",
                    "default": 0
                  },
                  "aggregate_by": {
                    "type": "string",
                    "description": "\"auto\" or \"model\", as in import_bound_book."
                  },
                  "cutover_date": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "description": "The day the bound book is counted as of (default today)."
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_integrations.fastbound.inventory_sync.boundbook_mismatches": {
      "post": {
        "tags": [
          "ffl_integrations"
        ],
        "summary": "Report in-stock firearms FastBound shows as disposed — dry run only.",
        "description": "The read-only face of `sync_in_stock_from_boundbook`: it runs the same\nreconcile with the dry-run switch hard-wired on, so it can never\nMaterial-Issue stock (there is no flag to turn writing on). Safe for\nread-only API consumers such as the nightly check. POST-only because it\npages the whole FastBound book on every call.\n\n**Auth (derived from code):** Roles: System Manager / Sales User / Sales Manager / Stock User / Stock Manager / Accounts User\n\nSource: `apps/ffl_integrations/ffl_integrations/fastbound/inventory_sync.py:62`",
        "operationId": "ffl_integrations.fastbound.inventory_sync.boundbook_mismatches",
        "responses": {
          "200": {
            "description": "Same dict as `sync_in_stock_from_boundbook` with `dry_run=1`: {dry_run: True, fb_disposed_count, would_remove, would_remove_count, consignment_held, consignment_held_count}. A dry run always reports every mismatch.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        }
      }
    },
    "/api/method/ffl_integrations.fastbound.inventory_sync.sync_in_stock_from_boundbook": {
      "post": {
        "tags": [
          "ffl_integrations"
        ],
        "summary": "Material-Issue in-stock firearms FastBound reports disposed.",
        "description": "**Auth (derived from code):** Roles: Sales Manager / Stock Manager / System Manager\n\n**Permissions:** Stock Manager / Sales Manager / System Manager.\n\nSource: `apps/ffl_integrations/ffl_integrations/fastbound/inventory_sync.py:33`",
        "operationId": "ffl_integrations.fastbound.inventory_sync.sync_in_stock_from_boundbook",
        "responses": {
          "200": {
            "description": "Dry run: {dry_run: True, fb_disposed_count, would_remove, would_remove_count, consignment_held, consignment_held_count}; real run: {dry_run: False, fb_disposed_count, removed, removed_count, errors}. Guns held at a consignment dealer are reported under consignment_held and are never removed by either run — \"disposed in FastBound, in stock here\" is their correct steady state, not a discrepancy (see in_stock_targets).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "dry_run": {
                    "description": "1 returns the would-remove list (each with its FastBound item id) without touching stock.",
                    "default": 0
                  },
                  "item_ids": {
                    "description": "On the real run, the ids the operator approved from the dry-run preview — only those are removed, and only if still disposed and in stock. That makes the confirmation authoritative: a firearm that became disposed between the preview and the apply is never removed without being shown."
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_integrations.fastbound.pos_4473.attest_paper_4473": {
      "post": {
        "tags": [
          "ffl_integrations"
        ],
        "summary": "Record that this order's 4473s were completed on PAPER, and book the",
        "description": "bound-book Disposition for every gun on the ticket.\n\nWhat the counter's \"Paper 4473 completed\" checkbox calls. A store with no\nFastBound account keeps paper 4473s and runs NICS by phone or the FBI portal;\nnothing will ever arrive to stamp this order Completed, so the cashier states\nit instead and the sale can be finished.\n\nNot manager-gated, unlike ``manager_override_4473``, and that difference is\ndeliberate. The override exists because something went WRONG and a manager is\naccountable for the exception. This is the store's ordinary, configured way of\nworking: the same cashier who filled the paper form in says it is filled in.\nMaking it a manager action would put a manager behind every single gun sale.\nThe two share a booking path, so the record is identically audited either way —\n``manual_override`` with the attesting user and a reason naming paper mode.\n\nAvailable ONLY while FFL Settings → Paper 4473 Mode is on. With FastBound\nrunning, a cashier must not be able to click past a pending 4473: that is what\nthe manager override is for.\n\nRecording the attestation is all this can do. Whether the form was actually\ncompleted and the background check actually cleared is a fact about the real\nworld (27 CFR 478.102 / 478.124) that no software can verify — hence storing\nWHO said so, and when.\n\nIdempotent per (invoice, serial): a double-tapped checkbox books one\ndisposition per gun, not two.\n\n**Auth (derived from code):** Roles: Sales User / Sales Manager / System Manager\n\n**Permissions:** POS 4473 roles (_check_perm).\n\nSource: `apps/ffl_integrations/ffl_integrations/fastbound/pos_4473.py:360`",
        "operationId": "ffl_integrations.fastbound.pos_4473.attest_paper_4473",
        "responses": {
          "200": {
            "description": "{ok, dispositions: [names], n_firearms}",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "invoice_name": {
                    "type": "string",
                    "description": "Draft POS Invoice docname."
                  }
                },
                "required": [
                  "invoice_name"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_integrations.fastbound.pos_4473.manager_override_4473": {
      "post": {
        "tags": [
          "ffl_integrations"
        ],
        "summary": "Manager force-complete a stuck firearm POS sale.",
        "description": "The escape hatch for when FastBound is the problem, not us: the 4473 was\ngenuinely completed in FastBound but never synced back (a serial edited in\nthe shared account so the webhook couldn't match, the disposition deleted by\na partner FFL, FastBound down). Normally the sale can't submit — the gate\nneeds a Retail Sale FFL Disposition (4473 Completed / NICS Proceed) for each\ngun. This mints exactly that, marked `manual_override` with WHO + WHY, so the\nbound book stays honest and the override is auditable.\n\nManager-gated (Sales Manager / System Manager) and reason-required. Idempotent\nper (invoice, serial). Does NOT push to FastBound — the operator reconciles the\nFastBound bound book separately.\n\n**Auth (derived from code):** Roles: Sales Manager / System Manager\n\nSource: `apps/ffl_integrations/ffl_integrations/fastbound/pos_4473.py:203`",
        "operationId": "ffl_integrations.fastbound.pos_4473.manager_override_4473",
        "responses": {
          "200": {
            "description": "{ok, dispositions: [names], n_firearms}",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "invoice_name": {
                    "type": "string",
                    "description": "Draft POS Invoice docname."
                  },
                  "reason": {
                    "type": "string",
                    "description": "free-text justification (required, stored on each disposition)."
                  }
                },
                "required": [
                  "invoice_name",
                  "reason"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_integrations.fastbound.pos_4473.start_4473_for_pos_invoice": {
      "post": {
        "tags": [
          "ffl_integrations"
        ],
        "summary": "Hold a POS / Sales Invoice in Draft while the cashier completes a 4473",
        "description": "in FastBound's UI.\n\n**Auth (derived from code):** Roles: Sales User / Sales Manager / System Manager\n\nSource: `apps/ffl_integrations/ffl_integrations/fastbound/pos_4473.py:87`",
        "operationId": "ffl_integrations.fastbound.pos_4473.start_4473_for_pos_invoice",
        "responses": {
          "200": {
            "description": "{ok: True, fastbound_url, n_firearms}",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "invoice_name": {
                    "type": "string",
                    "description": "POS Invoice or Sales Invoice docname."
                  },
                  "serial_by_item_row": {
                    "description": "{pos_invoice_item.name: \"ACTUAL-SERIAL\"}. Frappe transports dicts as JSON strings; we deserialize defensively."
                  }
                },
                "required": [
                  "invoice_name",
                  "serial_by_item_row"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_integrations.fastbound.pos_4473.start_transfer_for_pos_invoice": {
      "post": {
        "tags": [
          "ffl_integrations"
        ],
        "summary": "Build a customer-transfer POS Invoice (N $0 firearm lines + one Transfer",
        "description": "Fee line) then hand off to the 4473 kickoff.\n\nA transfer starts from an EMPTY POS cart: there's no saved invoice to mutate,\nand ERPNext won't let the cart save empty client-side. So the whole invoice is\nbuilt server-side — get_item_details fills item_name / uom / income_account (a\nclient add_child leaves those blank → mandatory-field error), and is_free_item=1\nmakes ERPNext SKIP the price-list fetch so each gun stays $0\n(get_item_details.py:1217). A second save then pins the economics (guns free,\nfee = configured amount) so no price-list lookup can override them. The\ncustomer is charged only the per-gun Transfer Fee; the guns are already theirs.\n\n**Auth (derived from code):** Roles: Sales User / Sales Manager / System Manager\n\n**Permissions:** POS 4473 roles (_check_perm).\n\nSource: `apps/ffl_integrations/ffl_integrations/fastbound/pos_4473.py:432`",
        "operationId": "ffl_integrations.fastbound.pos_4473.start_transfer_for_pos_invoice",
        "responses": {
          "200": {
            "description": "The 4473 kickoff result from start_4473_for_pos_invoice.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "serials": {
                    "type": "array",
                    "description": "Firearm serials to transfer — list or JSON string."
                  },
                  "fee_item": {
                    "type": "string",
                    "description": "The Transfer Fee service Item code."
                  },
                  "fee_amount": {
                    "description": "Per-gun fee amount."
                  },
                  "customer": {
                    "type": "string",
                    "description": "Buyer Customer name."
                  },
                  "pos_profile": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "description": "Optional POS Profile override."
                  },
                  "invoice_name": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "description": "Optional existing draft to reuse."
                  }
                },
                "required": [
                  "serials",
                  "fee_item",
                  "fee_amount",
                  "customer"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_integrations.fastbound.pos_4473.view_4473_pdf": {
      "get": {
        "tags": [
          "ffl_integrations"
        ],
        "summary": "Show a 4473's signed PDF (a Form 4473 Log row) inline in the browser tab.",
        "description": "Served from the row's private copy when it has one. Otherwise it is fetched\nlive from this site's own FastBound account — by the stored form id only, so\nnothing stored can point the server anywhere else — and a copy is queued.\nEvery view is written to Access Log.\n\n**Auth (derived from code):** Roles: Sales User / Sales Manager / System Manager\n\nSource: `apps/ffl_integrations/ffl_integrations/fastbound/pos_4473.py:612`",
        "operationId": "ffl_integrations.fastbound.pos_4473.view_4473_pdf",
        "responses": {
          "200": {
            "description": "None — the response body is the PDF (``Content-Type: application/pdf``, shown inline).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "null"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "parameters": [
          {
            "name": "log",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Form 4473 Log name whose PDF to show."
          }
        ]
      }
    },
    "/api/method/ffl_integrations.fastbound.pos_4473_recovery.manager_abandon_4473": {
      "post": {
        "tags": [
          "ffl_integrations"
        ],
        "summary": "Clear an abandoned counter order: drop FastBound's pending disposition",
        "description": "for every gun on it, then delete the draft that has been holding them.\n\nThe counter half of the DISP-2026-02000 fix, and deliberately a BUTTON. The\ndaily watch (``ffl_core.api.pending_4473.alert_overdue_pending_4473``) only\never raises a ToDo: deleting a bound-book record is an ATF-visible act and\nan unattended job may not decide to perform one.\n\nSame shape as :func:`manager_redo_4473` — manager gate, reason required,\naudit trail — with one difference that matters: the invoice does not\nsurvive, so the trail is an Error Log entry rather than a comment on a\ndocument that is about to disappear. The draft itself is *deleted*, not\ncancelled (a draft cannot be cancelled), which is how the POS closes an\nabandoned order anyway — ``ffl_core.api.pos_recycle_bin`` keeps it\nrestorable for as long as its Deleted Document row lives.\n\nFastBound goes FIRST, and is then RE-READ. A failure leaves everything as it\nwas; doing it the other way round would release the gun while the bound book\nstill held it, which is the state this whole change exists to end. The\nre-read is there because DELETE is not always the end of the hold — it can\nleave the item carrying a dangling ``dispositionId`` (observed 2026-07-07;\nsee :meth:`FastBoundClient.undispose_item`). The draft is the only POS trace\nof the order, so it is given up only once FastBound itself confirms every gun\nis free.\n\n**Auth (derived from code):** Roles: Sales Manager / System Manager\n\n**Permissions:** Sales Manager / System Manager (manager gate) + required reason.\n\nSource: `apps/ffl_integrations/ffl_integrations/fastbound/pos_4473_recovery.py:468`",
        "operationId": "ffl_integrations.fastbound.pos_4473_recovery.manager_abandon_4473",
        "responses": {
          "200": {
            "description": "``{ok, invoice, serials, deleted, skipped}`` — ``deleted`` lists the FastBound disposition ids removed, ``skipped`` the serials that had no pending disposition to remove.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "invoice_name": {
                    "type": "string",
                    "description": "The Draft POS Invoice to clear."
                  },
                  "reason": {
                    "type": "string",
                    "description": "Required audit reason."
                  }
                },
                "required": [
                  "invoice_name",
                  "reason"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_integrations.fastbound.pos_4473_recovery.manager_redo_4473": {
      "post": {
        "tags": [
          "ffl_integrations"
        ],
        "summary": "Re-open a COMPLETED 4473 — the only sanctioned way past the reset guard.",
        "description": "The counter path (``pos_4473.start_4473_for_pos_invoice``) refuses to reset a\ncompleted order, because a stale page clicking that button is exactly what\nbroke a past invoice. A genuine redo — wrong serial on the 4473, buyer\ndenied after the fact, the disposition voided in FastBound — comes through\nhere instead:\n\n* manager-gated (Sales Manager / System Manager) and reason-required;\n* cancels this order's committed Retail Sale dispositions — the bound-book\n  mirror of the 4473 being voided — so coverage drops to zero and\n  ``refresh_4473_status`` has nothing left to restore Completed from;\n* clears the webhook-owned field group as a WHOLE, keeping \"Pending while\n  still carrying a fastbound_disposition_id\" an impossible state. That shape\n  is the fingerprint of the bug this change closes, so it must not be\n  reachable through a legitimate path either. ``fastbound_url`` goes too: it\n  is the \"electronic 4473 in flight\" marker that makes ``attest_paper_4473``\n  refuse, and whose error message sends the cashier here;\n* marks this order's Paper / override Form 4473 Log rows Cancelled (the\n  status the webhook gives a voided electronic 4473), so the row the redone\n  form left behind can be told apart from the corrected one logged next.\n\nDoes NOT touch FastBound — void the disposition there first.\n\n**Auth (derived from code):** Roles: Sales Manager / System Manager\n\n**Permissions:** Sales Manager / System Manager (manager gate) + required reason.\n\nSource: `apps/ffl_integrations/ffl_integrations/fastbound/pos_4473_recovery.py:296`",
        "operationId": "ffl_integrations.fastbound.pos_4473_recovery.manager_redo_4473",
        "responses": {
          "200": {
            "description": "{ok, invoice, cancelled: [disposition names], n_cancelled}.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "invoice_name": {
                    "type": "string",
                    "description": "Draft POS Invoice whose 4473 is to be re-opened."
                  },
                  "reason": {
                    "type": "string",
                    "description": "Required audit reason."
                  }
                },
                "required": [
                  "invoice_name",
                  "reason"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_integrations.fastbound.pos_4473_recovery.refresh_4473_status": {
      "post": {
        "tags": [
          "ffl_integrations"
        ],
        "summary": "Re-read the authoritative 4473 state for a POS Invoice.",
        "description": "Layer 1 — the DB already says Completed/Proceed: the caller's page was just\nstale. Report and stop.\nLayer 2 — every firearm on the order has a committed Retail Sale disposition\nbut the doc-level flags say otherwise: the flags are stale, restore them from\nthe ledger. This is the past invoice shape.\nLayer 3 — coverage is incomplete: ask FastBound what it knows and REPORT it.\n\nNever writes NICS from a FastBound probe: the API does not carry the outcome,\nso inferring Proceed from \"the gun left the bound book\" would fabricate a\ncompliance fact.\n\n**Auth (derived from code):** Roles: Sales User / Sales Manager / System Manager\n\n**Permissions:** POS 4473 roles (_check_perm).\n\nSource: `apps/ffl_integrations/ffl_integrations/fastbound/pos_4473_recovery.py:213`",
        "operationId": "ffl_integrations.fastbound.pos_4473_recovery.refresh_4473_status",
        "responses": {
          "200": {
            "description": "{state: completed|repaired|no_firearm|no_serials|<incomplete>, invoice, covered, missing, [dispositions], [fastbound]}.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "invoice_name": {
                    "type": "string",
                    "description": "POS Invoice name."
                  }
                },
                "required": [
                  "invoice_name"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_integrations.fastbound.reconcile.apply_serial_fb_resolution": {
      "post": {
        "tags": [
          "ffl_integrations"
        ],
        "summary": "Apply the operator's per-field POS-vs-FastBound resolution choices.",
        "description": "Re-computes the diff first: a field no longer differing is skipped\n(already_resolved); a field whose FB value changed since shown is\nskipped (changed); the rest apply against fresh FB values. FB-wins\nwrite the Serial No; any POS-win triggers exactly one\npush_serial_to_fastbound.\n\n**Auth (derived from code):** Requires write permission on Serial No (Frappe DocType permission check).\n\nSource: `apps/ffl_integrations/ffl_integrations/fastbound/reconcile.py:190`",
        "operationId": "ffl_integrations.fastbound.reconcile.apply_serial_fb_resolution",
        "responses": {
          "200": {
            "description": "{ok, applied: {fb: [fields], pos: [fields]}, skipped: [{field, reason}], fastbound_updated} — ok False with a reason when the fresh diff isn't in \"ok\" state.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "serial": {
                    "type": "string",
                    "description": "Serial No name (needs Serial No write permission)."
                  },
                  "resolutions": {
                    "description": "{field: {\"choice\": \"pos\"|\"fb\", \"fb_value\": <value shown in the dialog>}} — dict or JSON string."
                  }
                },
                "required": [
                  "serial",
                  "resolutions"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_integrations.fastbound.reconcile.clear_not_in_bound_book": {
      "post": {
        "tags": [
          "ffl_integrations"
        ],
        "summary": "Undo :func:`mark_not_in_bound_book` — the record turned out to belong in the",
        "description": "bound book after all. Its sync error is emptied, so the daily retry pushes it again\nand the Dashboard lists it until it lands; a comment records who cleared it.\n\n**Auth (derived from code):** Roles: Stock Manager / System Manager\n\nSource: `apps/ffl_integrations/ffl_integrations/fastbound/reconcile.py:414`",
        "operationId": "ffl_integrations.fastbound.reconcile.clear_not_in_bound_book",
        "responses": {
          "200": {
            "description": "{ok: True, doctype, name}.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "doctype": {
                    "type": "string",
                    "description": "\"FFL Acquisition\" or \"FFL Disposition\"."
                  },
                  "name": {
                    "type": "string",
                    "description": "A record marked off the bound book."
                  }
                },
                "required": [
                  "doctype",
                  "name"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_integrations.fastbound.reconcile.compute_serial_fb_diff": {
      "post": {
        "tags": [
          "ffl_integrations"
        ],
        "summary": "Diff a Serial No's firearm identity against its FastBound item (read-only).",
        "description": "**Auth (derived from code):** Requires read permission on Serial No (Frappe DocType permission check).\n\nSource: `apps/ffl_integrations/ffl_integrations/fastbound/reconcile.py:108`",
        "operationId": "ffl_integrations.fastbound.reconcile.compute_serial_fb_diff",
        "responses": {
          "200": {
            "description": "{status: \"ok\" | \"not_in_fastbound\" | \"not_configured\" | \"fb_missing\" | \"fb_disposed\", serial, [fb_item_number], [in_sync], [diffs: [{field, pos_value, fb_value}]], [serial_diff: {pos_value, fb_value} or None]}. serial_diff compares the gun's ledger serial with FastBound's (case and spacing aside); it is outside `diffs` because a serial is changed with Correct Serial, not by picking a side here.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "serial": {
                    "type": "string",
                    "description": "Serial No name (needs Serial No read permission)."
                  }
                },
                "required": [
                  "serial"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_integrations.fastbound.reconcile.mark_not_in_bound_book": {
      "post": {
        "tags": [
          "ffl_integrations"
        ],
        "summary": "Record that a person checked this submitted record and it does not belong in the",
        "description": "bound book — e.g. an antique (pre-1899 receiver) booked by mistake, which FastBound\nrefuses because it never acquired the gun. The daily retry, the stuck digest and the\nDashboard's \"Not in the bound book yet\" list leave it alone from then on. The record\nitself is not cancelled (its stock leg is right); the reason, who marked it and the\nprevious sync error are kept as a comment.\n\n**Auth (derived from code):** Roles: Stock Manager / System Manager\n\nSource: `apps/ffl_integrations/ffl_integrations/fastbound/reconcile.py:355`",
        "operationId": "ffl_integrations.fastbound.reconcile.mark_not_in_bound_book",
        "responses": {
          "200": {
            "description": "{ok: True, doctype, name}.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "doctype": {
                    "type": "string",
                    "description": "\"FFL Acquisition\" or \"FFL Disposition\"."
                  },
                  "name": {
                    "type": "string",
                    "description": "The submitted record FastBound does not have."
                  },
                  "reason": {
                    "type": "string",
                    "description": "Why it is not a bound-book record (required)."
                  }
                },
                "required": [
                  "doctype",
                  "name",
                  "reason"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_integrations.fastbound.reconcile.match_serial_to_fastbound": {
      "post": {
        "tags": [
          "ffl_integrations"
        ],
        "summary": "Find and stamp the FastBound item id for an unlinked serial.",
        "description": "For a gun with no fastbound_item_id, finds its FastBound item by\nserial and stamps the id so it can be reconciled. Uses\nfind_item_by_serial (raises on >1 in-stock match — surfaced to the\noperator).\n\n**Auth (derived from code):** Requires write permission on Serial No (Frappe DocType permission check).\n\nSource: `apps/ffl_integrations/ffl_integrations/fastbound/reconcile.py:273`",
        "operationId": "ffl_integrations.fastbound.reconcile.match_serial_to_fastbound",
        "responses": {
          "200": {
            "description": "{ok: True, item_id} | {ok: True, already: True} | {ok: False, reason: \"not_found\" | \"not_configured\"}.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "serial": {
                    "type": "string",
                    "description": "Serial No name (needs Serial No write permission)."
                  }
                },
                "required": [
                  "serial"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_integrations.fastbound.reconcile.reconcile_record_to_fastbound": {
      "post": {
        "tags": [
          "ffl_integrations"
        ],
        "summary": "Link an already-booked POS record to an EXISTING FastBound record.",
        "description": "For the divergence class where the bound book already carries the event\n(entered directly in FastBound, or a push that landed but lost its id) and\nthe POS record is stuck with a sync error: re-pushing would double-book, so\nthe fix is to adopt the FastBound record's id. fastbound_id is locked after\nsubmit on both doctypes — this endpoint is the sanctioned entrance (the\n2026-08-21 JV-return incident had to do all of this through a bench\nconsole).\n\nEverything is verified against FastBound LIVE before anything is written\n(fail-closed): the ref must resolve to a real item whose serial matches the\nrecord's, and a Disposition additionally requires the item to actually be\ndisposed. An acquisition reconcile also repoints Serial No.fastbound_item_id\nthe way a successful push would.\n\n**Auth (derived from code):** Roles: Stock Manager / System Manager\n\nSource: `apps/ffl_integrations/ffl_integrations/fastbound/reconcile.py:443`",
        "operationId": "ffl_integrations.fastbound.reconcile.reconcile_record_to_fastbound",
        "responses": {
          "200": {
            "description": "{ok: True, fastbound_id, fb_item_id, fb_item_number, serial_repointed}.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "doctype": {
                    "type": "string",
                    "description": "\"FFL Acquisition\" or \"FFL Disposition\"."
                  },
                  "name": {
                    "type": "string",
                    "description": "The submitted, not-yet-linked record to link."
                  },
                  "fastbound_ref": {
                    "type": "string",
                    "description": "FastBound item GUID, or the bound-book item number shown in FastBound's UI (digits, e.g. \"01171\")."
                  }
                },
                "required": [
                  "doctype",
                  "name",
                  "fastbound_ref"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_integrations.fastbound.reconcile.retry_disposition_push": {
      "post": {
        "tags": [
          "ffl_integrations"
        ],
        "summary": "Re-run the FastBound push for a submitted FFL Disposition that failed.",
        "description": "``push_disposition_to_fastbound`` is a ``@frappe.task`` and nothing else —\nthere was no way to re-run one. A push that failed sat in\n``fastbound_sync_error`` until the next daily ``reconcile_failed_pushes``,\nwhich is up to 24 hours with a firearm out of the building and no bound-book\nentry for it. DISP-2026-02000 spent a day in exactly that state while the\nobstacle that caused the 400 had already been cleared by hand.\n\nA thin wrapper on purpose: it re-checks who may press it and what may be\npressed, then calls the task unchanged. Run INLINE rather than enqueued so\nthe operator sees the outcome — the task is already idempotent (it no-ops on\nan already-linked record) and carries its own retry/back-off.\n\nThe ``PUSHABLE_DISPOSITION_TYPES`` check is not decoration. A Retail Sale is\na 4473 disposition that FastBound's own wizard owns; pushing one from here\nwould book a to-individual transfer as a plain bound-book entry — a\ncompliance defect, not a sync error. The task would refuse it silently, so\nthis refuses it loudly instead of pretending to have done something. So does\nFastBound being switched off, for the same reason: the task returns silently\non a disabled integration, which behind a button reads as \"it failed again,\nreason unknown\".\n\nThe task's retry ladder is turned OFF here (``_retries=0``): an operator is\nwaiting, and the default four attempts with back-off can hold the desk for\n~80 seconds before showing anything.\n\n**Auth (derived from code):** Roles: Stock Manager / System Manager\n\n**Permissions:** Inventory roles (same gate as :func:`reconcile_record_to_fastbound`).\n\nSource: `apps/ffl_integrations/ffl_integrations/fastbound/reconcile.py:543`",
        "operationId": "ffl_integrations.fastbound.reconcile.retry_disposition_push",
        "responses": {
          "200": {
            "description": "``{ok, name, fastbound_id, fastbound_sync_error}`` — ``ok`` is True only when the push landed an id; a still-failing push returns ok False with the error FastBound gave, so the button can show it.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "name": {
                    "type": "string",
                    "description": "The submitted FFL Disposition to push."
                  }
                },
                "required": [
                  "name"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_integrations.fastbound.reconcile.scan_in_stock_fb_diffs": {
      "post": {
        "tags": [
          "ffl_integrations"
        ],
        "summary": "Kick off a background POS-vs-FastBound diff scan of in-stock firearms.",
        "description": "Scans every in-stock firearm with a fastbound_item_id. The result\n(which guns differ) is pushed via realtime (event 'fb_diff_scan_done')\n+ a Notification Log when the job finishes.\n\n**Auth (derived from code):** Requires read permission on Serial No (Frappe DocType permission check).\n\nSource: `apps/ffl_integrations/ffl_integrations/fastbound/reconcile.py:309`",
        "operationId": "ffl_integrations.fastbound.reconcile.scan_in_stock_fb_diffs",
        "responses": {
          "200": {
            "description": "{\"ok\": True, \"started\": True} — the scan itself is asynchronous.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        }
      }
    },
    "/api/method/ffl_integrations.fastbound.tasks.push_serial_to_fastbound": {
      "post": {
        "tags": [
          "ffl_integrations"
        ],
        "summary": "Push a post-acquisition manufacturer / importer correction for ONE",
        "description": "firearm to FastBound, editing the bound-book item in place (PUT /Items/{id})\n— no delete/recreate, FastBound audit-logs the edit.\n\nCalled synchronously from the Serial No form's \"sync to FastBound?\" confirm\nafter an operator edits a per-unit manufacturer / importer.\n\n**Auth (derived from code):** Requires write permission on Serial No (Frappe DocType permission check).\n\nSource: `apps/ffl_integrations/ffl_integrations/fastbound/tasks.py:720`",
        "operationId": "ffl_integrations.fastbound.tasks.push_serial_to_fastbound",
        "responses": {
          "200": {
            "description": "{\"ok\": True, \"item_id\": ...} on success; {\"ok\": False, \"reason\": \"not_in_fastbound\" | \"not_configured\"} for the expected not-pushed cases (rather than raising) so the form can show a tidy message. A store running with FastBound switched off reports \"not_configured\" too — from the operator's side it is the same fact, and the edit they just made is saved locally either way.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "serial": {
                    "type": "string",
                    "description": "Serial No name (must carry a fastbound_item_id)."
                  }
                },
                "required": [
                  "serial"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_integrations.fastbound.webhook.fastbound_event": {
      "post": {
        "tags": [
          "webhooks"
        ],
        "summary": "Single FastBound webhook entry point (guest, HMAC-verified).",
        "description": "**Auth (derived from code):** Guest — no session; the endpoint verifies the caller itself (HMAC signature, HTTP Basic credentials or a one-time token).\n\n**Payload:** FastBound's webhook JSON body; the event name selects the handler. The X-FastBound-Signature header must carry a valid HMAC over the raw body (secret configured in FastBound Settings).\n\nSource: `apps/ffl_integrations/ffl_integrations/fastbound/webhook.py:1131`",
        "operationId": "ffl_integrations.fastbound.webhook.fastbound_event",
        "responses": {
          "200": {
            "description": "200 with a minimal body ({ok, event/handled/error}) on success. 401 when the HMAC signature is missing, malformed or fails — and also, word for word, when the integration is switched off on this site (see below). Every other failure path logs + returns 200 to keep FastBound from retrying.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "security": []
      }
    },
    "/api/method/ffl_integrations.ffl_integrations.doctype.data_service_settings.data_service_settings.test_connection": {
      "post": {
        "tags": [
          "ffl_integrations"
        ],
        "summary": "Settings toolbar: catalog health for every enabled house through the",
        "description": "site-wide service (or this site's own tables when the catalog source is\nLocal), recording the contract version on the Status tab.\n\n**Auth (derived from code):** Roles: System Manager\n\n**Permissions:** System Manager.\n\nSource: `apps/ffl_integrations/ffl_integrations/ffl_integrations/doctype/data_service_settings/data_service_settings.py:103`",
        "operationId": "ffl_integrations.ffl_integrations.doctype.data_service_settings.data_service_settings.test_connection",
        "responses": {
          "200": {
            "description": "{checks: [{label, ok: bool|None, detail}]}",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        }
      }
    },
    "/api/method/ffl_integrations.ffl_integrations.doctype.lipseys_settings.lipseys_settings.test_connection": {
      "post": {
        "tags": [
          "ffl_integrations"
        ],
        "summary": "Settings toolbar: catalog service + a sign-in and one read per Lipsey's login.",
        "description": "Read-only at Lipsey's: it places no order.\n\n**Auth (derived from code):** Roles: System Manager\n\n**Permissions:** System Manager.\n\nSource: `apps/ffl_integrations/ffl_integrations/ffl_integrations/doctype/lipseys_settings/lipseys_settings.py:24`",
        "operationId": "ffl_integrations.ffl_integrations.doctype.lipseys_settings.lipseys_settings.test_connection",
        "responses": {
          "200": {
            "description": "{checks: [{label, ok: bool|None, detail}]}",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        }
      }
    },
    "/api/method/ffl_integrations.ffl_integrations.doctype.rsr_settings.rsr_settings.test_connection": {
      "post": {
        "tags": [
          "ffl_integrations"
        ],
        "summary": "Settings toolbar: catalog health, the feed login (Local catalog only, no",
        "description": "download) and a Direct Connect authentication round trip per configured\naccount.\n\n**Auth (derived from code):** Roles: System Manager\n\n**Permissions:** System Manager.\n\nSource: `apps/ffl_integrations/ffl_integrations/ffl_integrations/doctype/rsr_settings/rsr_settings.py:20`",
        "operationId": "ffl_integrations.ffl_integrations.doctype.rsr_settings.rsr_settings.test_connection",
        "responses": {
          "200": {
            "description": "{checks: [{label, ok: bool|None, detail}]}",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        }
      }
    },
    "/api/method/ffl_integrations.ffl_integrations.doctype.sports_south_settings.sports_south_settings.test_connection": {
      "post": {
        "tags": [
          "ffl_integrations"
        ],
        "summary": "Settings toolbar: catalog service + orders/invoices authentication.",
        "description": "**Auth (derived from code):** Roles: System Manager\n\n**Permissions:** System Manager.\n\nSource: `apps/ffl_integrations/ffl_integrations/ffl_integrations/doctype/sports_south_settings/sports_south_settings.py:25`",
        "operationId": "ffl_integrations.ffl_integrations.doctype.sports_south_settings.sports_south_settings.test_connection",
        "responses": {
          "200": {
            "description": "{checks: [{label, ok: bool|None, detail}]}",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        }
      }
    },
    "/api/method/ffl_integrations.gunbroker.client_api.clear_sold_unknown_now": {
      "post": {
        "tags": [
          "ffl_integrations"
        ],
        "summary": "Clear the \"may already be sold on GunBroker\" flag after checking.",
        "description": "**Auth (derived from code):** Roles: Stock Manager / System Manager\n\nSource: `apps/ffl_integrations/ffl_integrations/gunbroker/client_api.py:390`",
        "operationId": "ffl_integrations.gunbroker.client_api.clear_sold_unknown_now",
        "responses": {
          "200": {
            "description": "{\"ok\": True, \"changed\": bool}.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "serial_no": {
                    "type": "string",
                    "description": "The Serial No to clear."
                  },
                  "note": {
                    "type": "string",
                    "description": "What was checked, recorded as a Comment on the serial. Required — this flag exists to stop a gun being sold twice, and lifting it is an assertion somebody should be able to stand behind afterwards."
                  }
                },
                "required": [
                  "serial_no",
                  "note"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_integrations.gunbroker.client_api.end_item_listing_now": {
      "post": {
        "tags": [
          "ffl_integrations"
        ],
        "summary": "End this Item's GunBroker listing.",
        "description": "**Auth (derived from code):** Roles: Stock Manager / System Manager\n\nSource: `apps/ffl_integrations/ffl_integrations/gunbroker/client_api.py:356`",
        "operationId": "ffl_integrations.gunbroker.client_api.end_item_listing_now",
        "responses": {
          "200": {
            "description": "{\"ok\": True, \"strategy\": \"delete_endpoint\", \"confirmed\": True} when GunBroker confirmed it, or a pending-manual result naming the listing that a person still has to end there.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "item_code": {
                    "type": "string",
                    "description": "The Item whose listing should end."
                  },
                  "reason": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "description": "Optional note recorded in the alert if it cannot be ended automatically."
                  }
                },
                "required": [
                  "item_code"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_integrations.gunbroker.client_api.end_listing_now": {
      "post": {
        "tags": [
          "ffl_integrations"
        ],
        "summary": "End this gun's GunBroker listing.",
        "description": "**Auth (derived from code):** Roles: Stock Manager / System Manager\n\nSource: `apps/ffl_integrations/ffl_integrations/gunbroker/client_api.py:204`",
        "operationId": "ffl_integrations.gunbroker.client_api.end_listing_now",
        "responses": {
          "200": {
            "description": "{\"ok\": True, \"strategy\": \"delete_endpoint\", \"confirmed\": True} when GunBroker confirmed the listing is inactive. Otherwise \"confirmed\" is False and the answer always carries \"pending_manual\": True, \"gb_url\" (the listing, to end by hand) and a \"message\" saying it can still be bought — whether the cause was the Manual Only setting, a failed call, or a read-back that still showed it active, because the person reading this has to do the same thing in every one of those cases. \"strategy\" says whether the system will retry by itself, and \"downgraded\": True appears when GunBroker withdrew permission and the setting was changed as a result.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "serial_no": {
                    "type": "string",
                    "description": "The Serial No whose listing should end."
                  },
                  "reason": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "description": "Optional note recorded in the alert if it cannot be ended automatically."
                  }
                },
                "required": [
                  "serial_no"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_integrations.gunbroker.client_api.fetch_listing_defaults": {
      "post": {
        "tags": [
          "ffl_integrations"
        ],
        "summary": "Read the GunBroker account's own listing defaults.",
        "description": "**Auth (derived from code):** Roles: System Manager\n\nSource: `apps/ffl_integrations/ffl_integrations/gunbroker/client_api.py:39`",
        "operationId": "ffl_integrations.gunbroker.client_api.fetch_listing_defaults",
        "responses": {
          "200": {
            "description": "{\"ok\": True, \"defaults\": {...}} — the raw account defaults, including ``gatewayEnabled`` and ``standardTextID``, for filling in this store's settings.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        }
      }
    },
    "/api/method/ffl_integrations.gunbroker.client_api.item_listing_offer": {
      "post": {
        "tags": [
          "ffl_integrations"
        ],
        "summary": "What the Send dialog offers for a model: the figures a listing sent now would",
        "description": "carry, so the person decides with them in front of them.\n\n**Auth (derived from code):** Roles: Stock Manager / System Manager\n\nSource: `apps/ffl_integrations/ffl_integrations/gunbroker/client_api.py:294`",
        "operationId": "ffl_integrations.gunbroker.client_api.item_listing_offer",
        "responses": {
          "200": {
            "description": "{\"is_model\": <true for a uniform-price firearm>, \"title\", \"sellable\" (guns that can be promised now, null when a sales channel could not say), \"price\" (what GunBroker would show: the web store's price today), \"regular_price\", \"on_sale\" (true when a promotion makes price lower), \"sale_to\" (the promotion's last day, or \"\"), \"category\": {\"id\" (0 for none), \"name\", \"ambiguous\" (the category depends on a year the Item lacks)}, \"shipping\": {\"own\", \"default\", \"free\", \"effective\"}, \"premium\": {\"featured\", \"showcase\", \"sponsored_onsite\", \"view_counter\"} (recorded on the Item; a listing made now buys them again)}.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "item_code": {
                    "type": "string",
                    "description": "The uniform-price firearm Item about to be listed."
                  }
                },
                "required": [
                  "item_code"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_integrations.gunbroker.client_api.item_listing_status": {
      "post": {
        "tags": [
          "ffl_integrations"
        ],
        "summary": "What this Item's GunBroker listing looks like, locally and remotely.",
        "description": "**Auth (derived from code):** Roles: Stock Manager / System Manager\n\nSource: `apps/ffl_integrations/ffl_integrations/gunbroker/client_api.py:374`",
        "operationId": "ffl_integrations.gunbroker.client_api.item_listing_status",
        "responses": {
          "200": {
            "description": "{\"ok\": True, \"state\": ..., \"gb_item_id\": ..., \"gb_sync_error\": ..., \"quantity_local\": <n>, \"quantity_pushed\": <n>, \"remote\": {...} | None} — the two quantities are what show a drift between stock and the listing.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "item_code": {
                    "type": "string",
                    "description": "The Item to report on."
                  }
                },
                "required": [
                  "item_code"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_integrations.gunbroker.client_api.listing_offer": {
      "post": {
        "tags": [
          "ffl_integrations"
        ],
        "summary": "What the Send dialog offers for one gun: the figures a listing would",
        "description": "carry if nothing were changed, and the choices GunBroker allows.\n\n**Auth (derived from code):** Roles: Stock Manager / System Manager\n\nSource: `apps/ffl_integrations/ffl_integrations/gunbroker/client_api.py:122`",
        "operationId": "ffl_integrations.gunbroker.client_api.listing_offer",
        "responses": {
          "200": {
            "description": "{\"title\", \"derived_title\", \"price\", \"pos_price\", \"type\", \"types\", \"starting_bid\", \"reserve_price\", \"buy_now_price\", \"duration\", \"durations\", \"auto_relist\", \"auto_relist_options\": [{\"value\", \"label\"}], \"shipping\": {\"own\", \"default\", \"free\", \"effective\"}, \"category\": {\"id\": <the category it would list under, 0 for none>, \"options\": [{\"id\", \"name\"}]}, \"premium\": {\"featured\", \"showcase\", \"sponsored_onsite\", \"view_counter\"} (the paid promotions recorded on the gun, each true/false; a listing made now buys them again), \"condition\" (the code recorded for this gun, 0 for none), \"derived_condition\" (what the Item alone gives), \"condition_options\" (the codes allowed: only the derived one for an antique)}.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "serial_no": {
                    "type": "string",
                    "description": "The Serial No about to be listed."
                  }
                },
                "required": [
                  "serial_no"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_integrations.gunbroker.client_api.listing_ship_cost": {
      "post": {
        "tags": [
          "ffl_integrations"
        ],
        "summary": "What a listing of this record would charge the buyer for shipping.",
        "description": "**Auth (derived from code):** Roles: Stock Manager / System Manager\n\nSource: `apps/ffl_integrations/ffl_integrations/gunbroker/client_api.py:147`",
        "operationId": "ffl_integrations.gunbroker.client_api.listing_ship_cost",
        "responses": {
          "200": {
            "description": "{\"own\": <rate saved on the record, 0 for none>, \"default\": <the store default for this record's kind>, \"free\": <true when the gun is marked free shipping, always false for an Item>, \"effective\": <the rate a listing sent now would carry, 0 when free>}.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "doctype": {
                    "type": "string",
                    "description": "\"Serial No\" for a gun, \"Item\" for a model-level listing."
                  },
                  "name": {
                    "type": "string",
                    "description": "The record."
                  }
                },
                "required": [
                  "doctype",
                  "name"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_integrations.gunbroker.client_api.listing_status": {
      "post": {
        "tags": [
          "ffl_integrations"
        ],
        "summary": "Report what this POS and GunBroker each think of one listing.",
        "description": "**Auth (derived from code):** Roles: Stock Manager / System Manager\n\nSource: `apps/ffl_integrations/ffl_integrations/gunbroker/client_api.py:229`",
        "operationId": "ffl_integrations.gunbroker.client_api.listing_status",
        "responses": {
          "200": {
            "description": "{\"ok\": True, \"state\": <one of unlisted|push_pending|listed|end_pending| sold|sold_unknown|ended>, \"gb_item_id\": str, \"gb_sync_error\": str, \"remote\": {...}|None} — ``remote`` is what GunBroker currently says, or None when there is no listing to ask about. Read-only.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "serial_no": {
                    "type": "string",
                    "description": "The Serial No to inspect."
                  }
                },
                "required": [
                  "serial_no"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_integrations.gunbroker.client_api.push_item_now": {
      "post": {
        "tags": [
          "ffl_integrations"
        ],
        "summary": "List one Item on GunBroker as a quantity listing.",
        "description": "Ammunition, optics, parts — one listing standing for the stock on hand — and a\nuniform-price firearm, listed as a MODEL: one listing standing for the guns that\nare free to sell, filed under the bare item code with the licence requirement on.\nA gun priced one by one is refused here; those are listed one at a time from the\nSerial No form.\n\n**Auth (derived from code):** Roles: Stock Manager / System Manager\n\nSource: `apps/ffl_integrations/ffl_integrations/gunbroker/client_api.py:246`",
        "operationId": "ffl_integrations.gunbroker.client_api.push_item_now",
        "responses": {
          "200": {
            "description": "{\"ok\": True, \"gb_item_id\": \"<GunBroker item number>\", \"quantity\": <n>, \"warnings\": [...]} on success, or {\"ok\": False, \"skipped\": \"<reason>\", \"message\": \"<why>\"} when a guard refused. A refusal is a normal answer.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "item_code": {
                    "type": "string",
                    "description": "The Item to list."
                  },
                  "relist": {
                    "description": "Pass 1 when the operator is deliberately re-listing something that was ended by hand. It lifts that one sentinel and nothing else.",
                    "default": 0
                  },
                  "ship_cost": {
                    "description": "The buyer-paid shipping rate for this listing, saved on the Item before it is listed. Omit to keep what is there; 0 clears it, so the default in GunBroker Settings applies (the long gun / handgun one for a model, the accessory / ammo one otherwise)."
                  },
                  "listing": {
                    "description": "For a model only, the terms chosen in the Send dialog, as JSON: {\"type\": \"Fixed Price\", \"premium\": {\"featured\": 0, \"showcase\": 0, \"sponsored_onsite\": 0, \"view_counter\": 0}}. \"premium\" is GunBroker's paid promotions (extra fees, one per ticked flag): they can only be bought here, when the listing is created, never added to a live one, and a re-listing the system does by itself after a sell-out never buys them. A \"premium\" object replaces all four flags (omitted names count as off); omit the key to keep the recorded ones; an unknown name is refused. A model lists at a fixed price only, and its title, price, category and condition follow its Item, so any other key is refused. Omit \"listing\" to list on the terms already recorded."
                  }
                },
                "required": [
                  "item_code"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_integrations.gunbroker.client_api.push_serial_now": {
      "post": {
        "tags": [
          "ffl_integrations"
        ],
        "summary": "List one firearm on GunBroker.",
        "description": "**Auth (derived from code):** Roles: Stock Manager / System Manager\n\nSource: `apps/ffl_integrations/ffl_integrations/gunbroker/client_api.py:56`",
        "operationId": "ffl_integrations.gunbroker.client_api.push_serial_now",
        "responses": {
          "200": {
            "description": "{\"ok\": True, \"gb_item_id\": \"<GunBroker item number>\", \"gb_url\": \"<the listing's page>\", \"warnings\": [...]} on success (\"no_upc\" among the warnings means GunBroker had no UPC to fill Manufacturer / Model / Caliber from), or {\"ok\": False, \"skipped\": \"<reason>\", \"message\": \"<why>\"} when a guard refused. A refusal is a normal answer, not an error.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "serial_no": {
                    "type": "string",
                    "description": "The Serial No to list."
                  },
                  "relist": {
                    "description": "Pass 1 when the operator is deliberately re-listing a gun that was ended by hand. It lifts that one sentinel and nothing else — it cannot override custody, pricing or cross-channel guards.",
                    "default": 0
                  },
                  "ship_cost": {
                    "description": "The buyer-paid shipping rate for this listing, saved on the Serial No before it is listed. Omit to keep what is there; 0 clears it, so the default in GunBroker Settings applies."
                  },
                  "listing": {
                    "description": "The terms chosen for this listing, as JSON: {\"type\": \"Fixed Price\" | \"Auction\", \"title\": \"\", \"price\": 0, \"starting_bid\": 0, \"reserve_price\": 0, \"buy_now_price\": 0, \"duration\": 7, \"auto_relist\": 2, \"condition\": 0, \"premium\": {\"featured\": 0, \"showcase\": 0, \"sponsored_onsite\": 0, \"view_counter\": 0}}. Saved on the Serial No before it is listed and refused, with the reason, when GunBroker would refuse it. An empty title or a zero price follows the item name / the POS sell price. \"condition\" is GunBroker's code for this gun: 1 Factory New, 2 New Old Stock, 3 Used; 0 follows the Item (used or not), and an antique always lists as Used. Omit the key to keep what is recorded. \"premium\" is GunBroker's paid promotions (extra fees, one per ticked flag): they can only be bought here, when the listing is created, never added to a live one, and a POS relist buys the recorded ones again. A \"premium\" object replaces all four flags (omitted names count as off); omit the key to keep the recorded ones; an unknown name is refused. Omit \"listing\" to list on the terms already recorded (fixed price by default, no paid promotions unless recorded)."
                  },
                  "category_id": {
                    "description": "The GunBroker category chosen in the Send dialog, one of the ``category.options`` listing_offer returned. Saved on the gun's Item, so every gun of that model lists there, and put back if the push is refused. Omit to keep the category the gun resolves to now."
                  },
                  "free_shipping": {
                    "description": "1 lists the gun with free shipping (seller pays, whatever the rate), 0 takes that off. Saved on the Serial No. Omit to keep what is there."
                  }
                },
                "required": [
                  "serial_no"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_integrations.gunbroker.client_api.replace_pictures_now": {
      "post": {
        "tags": [
          "ffl_integrations"
        ],
        "summary": "Replace a live listing's photos with the ones a new push would send now.",
        "description": "For when the photos or the store's watermark changed after the listing went\nup. GunBroker keeps the search thumbnail it took at listing time.\n\n**Auth (derived from code):** Roles: System Manager\n\nSource: `apps/ffl_integrations/ffl_integrations/gunbroker/client_api.py:181`",
        "operationId": "ffl_integrations.gunbroker.client_api.replace_pictures_now",
        "responses": {
          "200": {
            "description": "{\"ok\": True, \"gb_item_id\": ..., \"uploaded\": n, \"removed\": n, \"warnings\": [...]}, or a skip dict (not listed, an auction with bids, no photos, GunBroker refused).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "serial_no": {
                    "type": "string",
                    "description": "The gun whose per-serial listing to update.",
                    "default": ""
                  },
                  "item_code": {
                    "type": "string",
                    "description": "Or the model / item whose item-level listing to update.",
                    "default": ""
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_integrations.gunbroker.client_api.reprice_item_now": {
      "post": {
        "tags": [
          "ffl_integrations"
        ],
        "summary": "Send this Item's current selling rate to its GunBroker listing.",
        "description": "A model (uniform-price firearm) is sent the web store's price today, a running\npromotion included; anything else its standard rate.\n\n**Auth (derived from code):** Roles: Stock Manager / System Manager\n\nSource: `apps/ffl_integrations/ffl_integrations/gunbroker/client_api.py:317`",
        "operationId": "ffl_integrations.gunbroker.client_api.reprice_item_now",
        "responses": {
          "200": {
            "description": "{\"ok\": True, \"fixed_price\": <price>, \"verified\": True} when the listing was read back showing the new price, otherwise a skip dict.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "item_code": {
                    "type": "string",
                    "description": "The Item whose listing should be repriced."
                  }
                },
                "required": [
                  "item_code"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_integrations.gunbroker.client_api.reprice_serial_now": {
      "post": {
        "tags": [
          "ffl_integrations"
        ],
        "summary": "Send this gun's current sell price to its GunBroker listing.",
        "description": "**Auth (derived from code):** Roles: Stock Manager / System Manager\n\nSource: `apps/ffl_integrations/ffl_integrations/gunbroker/client_api.py:165`",
        "operationId": "ffl_integrations.gunbroker.client_api.reprice_serial_now",
        "responses": {
          "200": {
            "description": "{\"ok\": True, \"fixed_price\": <price>, \"verified\": True} — verified means the listing was read back and shows the new price, which is the only proof that counts here. Otherwise a skip dict.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "serial_no": {
                    "type": "string",
                    "description": "The Serial No whose listing should be repriced."
                  }
                },
                "required": [
                  "serial_no"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_integrations.gunbroker.client_api.sync_item_quantity_now": {
      "post": {
        "tags": [
          "ffl_integrations"
        ],
        "summary": "Push this Item's stock count to its GunBroker listing.",
        "description": "Normally automatic — every stock movement of a listed item triggers it — so\nthis is the manual repair for a count that has drifted. A model's count is the\nguns free to sell less the units GunBroker has sold that no order has brought\nin yet; when GunBroker cannot be read nothing is sent.\n\n**Auth (derived from code):** Roles: Stock Manager / System Manager\n\nSource: `apps/ffl_integrations/ffl_integrations/gunbroker/client_api.py:335`",
        "operationId": "ffl_integrations.gunbroker.client_api.sync_item_quantity_now",
        "responses": {
          "200": {
            "description": "{\"ok\": True, \"quantity\": <n>} — with \"unchanged\": True when GunBroker already held that number, or the end-listing result when stock is zero (GunBroker rejects a quantity of zero, so selling out ends the listing).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "item_code": {
                    "type": "string",
                    "description": "The listed Item."
                  }
                },
                "required": [
                  "item_code"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_integrations.gunbroker.client_api.sync_orders_now": {
      "post": {
        "tags": [
          "ffl_integrations"
        ],
        "summary": "Run the GunBroker order poll now instead of waiting for the schedule.",
        "description": "Queued rather than run inline: a poll can walk many pages and fetch every\norder in full, which is far too long to hold a Desk request open. The job is\nde-duplicated against the scheduled one, so pressing the button while a poll\nis already running joins it rather than starting a second.\n\n**Auth (derived from code):** Roles: System Manager\n\nSource: `apps/ffl_integrations/ffl_integrations/gunbroker/client_api.py:411`",
        "operationId": "ffl_integrations.gunbroker.client_api.sync_orders_now",
        "responses": {
          "200": {
            "description": "{\"queued\": True}.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        }
      }
    },
    "/api/method/ffl_integrations.gunbroker.client_api.test_connection": {
      "post": {
        "tags": [
          "ffl_integrations"
        ],
        "summary": "Check the GunBroker credentials and report which environment they reach.",
        "description": "**Auth (derived from code):** Roles: System Manager\n\nSource: `apps/ffl_integrations/ffl_integrations/gunbroker/client_api.py:24`",
        "operationId": "ffl_integrations.gunbroker.client_api.test_connection",
        "responses": {
          "200": {
            "description": "{\"ok\": True, \"sandbox\": bool, \"base_url\": str, \"server_time\": str, \"account\": str, \"gateway_enabled\": bool, \"warnings\": [str]} — or {\"ok\": False, \"sandbox\": bool, \"error\": str} when it could not connect. ``sandbox`` is included either way so an operator can see at a glance which GunBroker was just contacted.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        }
      }
    },
    "/api/method/ffl_integrations.gunbroker.fulfillment.assign_gb_unit_serial": {
      "post": {
        "tags": [
          "ffl_integrations"
        ],
        "summary": "Name the gun that fills one unit of a model-level GunBroker order.",
        "description": "Reserves the gun for the order (the claim becomes a hold), tells the other\nstorefronts it is gone, and records who assigned it and when. Naming a\ndifferent gun for a unit that already has one swaps them: the old gun is\nreleased only if this order holds it. An empty ``serial_no`` unassigns the\nunit, which makes it an open claim again. Calling it again with the gun the\nunit already has changes nothing.\n\nRefused: a gun of another model (a model pooled under this one must be filed\nunder it first), a customer's consignment or transfer gun, one in custody,\none the order already holds for another unit, one that is not free (held by a\ncounter order or another channel, out on consignment, possibly already sold on\nGunBroker), and, on a Type 03 collector order, a gun not old enough to be a\ncurio or relic. Nothing is changed on a refusal.\n\n**Auth (derived from code):** Roles: Sales User / Sales Manager / Stock Manager / System Manager\n\n**Permissions:** Counter roles.\n\nSource: `apps/ffl_integrations/ffl_integrations/gunbroker/fulfillment.py:1027`",
        "operationId": "ffl_integrations.gunbroker.fulfillment.assign_gb_unit_serial",
        "responses": {
          "200": {
            "description": "{ok, serial, row: the refreshed Pending Order card}.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "gunbroker_order": {
                    "type": "string",
                    "description": "GunBroker Order name (must be Pending Fulfillment)."
                  },
                  "row_name": {
                    "type": "string",
                    "description": "The unit, as the card gives it: ``<gunbroker item id>:<unit number>``."
                  },
                  "serial_no": {
                    "type": "string",
                    "description": "The gun's Serial No. Empty unassigns the unit.",
                    "default": ""
                  }
                },
                "required": [
                  "gunbroker_order",
                  "row_name"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_integrations.gunbroker.fulfillment.correct_payment_details": {
      "post": {
        "tags": [
          "ffl_integrations"
        ],
        "summary": "Repair the deposit date (and cheque number) recorded on a GunBroker order.",
        "description": "For the row that cannot otherwise be fixed. The four payment fields are\nread-only on the form — they are a record of what was banked, not something\nto retype — and the document refuses to save when a mode is recorded with no\ndeposit date. A row in that state (a direct database write, an import, a\nhalf-finished edit) is reported by the daily audit and then cannot be\ncorrected through the Desk at all: the field will not accept typing and\nopening the form and saving throws.\n\nDeliberately narrow: the date and the reference number, nothing else. The\namount, the mode and whether the order is paid are what was banked — those\nare mark_payment_received's, and once a receipt is posted they are an\naccounting correction rather than an edit.\n\n**Auth (derived from code):** Roles: System Manager\n\n**Permissions:** System Manager.\n\nSource: `apps/ffl_integrations/ffl_integrations/gunbroker/fulfillment.py:734`",
        "operationId": "ffl_integrations.gunbroker.fulfillment.correct_payment_details",
        "responses": {
          "200": {
            "description": "{ok, received_on, reference_no}.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "gunbroker_order": {
                    "type": "string",
                    "description": "GunBroker Order name."
                  },
                  "received_on": {
                    "type": "string",
                    "description": "The day the money went into the bank. Not in the future."
                  },
                  "reference_no": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "description": "Cheque or money-order number, when that is the wrong part."
                  }
                },
                "required": [
                  "gunbroker_order",
                  "received_on"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_integrations.gunbroker.fulfillment.dispose_gb_order": {
      "post": {
        "tags": [
          "ffl_integrations"
        ],
        "summary": "Book the bound-book exit for a paid GunBroker order (the Dispose action).",
        "description": "One submitted \"FFL Transfer\" disposition per regulated gun, each of which\nissues its own stock-out and queues its own FastBound push. Idempotent on\n{serial, gunbroker_order}. An ANTIQUE on the order gets no disposition —\nit is GCA-exempt, so it is issued straight out of stock instead\n(``_retire_antique_units``). Whether a dealer is involved at all is\n``needs_dealer``: an order that is all antiques and names no licence ships\nto the buyer, and that decision is written to ``ships_direct`` for the\ninvoice and the card to read. A serialized unit that is neither a\nregulated firearm nor an antique is refused outright. The revenue invoice\nis raised at the end and a failure there does not roll back the\ndispositions — create_gb_invoice_now retries.\n\n**Auth (derived from code):** Roles: Sales User / Sales Manager / Stock Manager / System Manager\n\n**Permissions:** Counter roles.\n\nSource: `apps/ffl_integrations/ffl_integrations/gunbroker/fulfillment.py:1209`",
        "operationId": "ffl_integrations.gunbroker.fulfillment.dispose_gb_order",
        "responses": {
          "200": {
            "description": "{ok, dispositions: [names], disposed_count, retired: [antique serials issued out with no disposition], issued: [item-level quantities taken out of stock], sales_invoice, invoice_status}.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "gunbroker_order": {
                    "type": "string",
                    "description": "GunBroker Order name (must be Pending Fulfillment)."
                  },
                  "cr_details": {
                    "description": "Staff verification captured in the dispose dialog for a Type 03 (Curio & Relic) order. Dict from Python, JSON string from the browser. Only consulted for a C&R order, and refused on one that is not."
                  },
                  "locations": {
                    "description": "Optional {gb_item_id: Storage Location} -- where in the store staff took each item-level line from (see get_dispose_stock_lines). The units leave that location; a line left out goes to the \"to confirm\" list on the Storage Locations page."
                  }
                },
                "required": [
                  "gunbroker_order"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_integrations.gunbroker.fulfillment.enter_gb_tracking": {
      "post": {
        "tags": [
          "ffl_integrations"
        ],
        "summary": "Send GunBroker the tracking number of a label bought outside the POS shipment.",
        "description": "For a label bought on an order staff built in ShipStation by hand: the\nPOS's own shipment has no label, so the poll has nothing to find. The\nnumber must belong to a live (not voided) ShipStation label — that is\nstill the \"a label was bought\" fact the write-back waits for — and it is\nthen sent the same way the poll sends one.\n\n**Auth (derived from code):** Roles: Sales User / Sales Manager / Stock Manager / System Manager\n\n**Permissions:** Counter roles.\n\nSource: `apps/ffl_integrations/ffl_integrations/gunbroker/fulfillment.py:1751`",
        "operationId": "ffl_integrations.gunbroker.fulfillment.enter_gb_tracking",
        "responses": {
          "200": {
            "description": "push_tracking's result: {ok, tracking_number, carrier, steps, ...}.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "gunbroker_order": {
                    "type": "string",
                    "description": "GunBroker Order name (disposed, invoice posted)."
                  },
                  "tracking_number": {
                    "type": "string",
                    "description": "The tracking number on the label."
                  }
                },
                "required": [
                  "gunbroker_order",
                  "tracking_number"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_integrations.gunbroker.fulfillment.get_dispose_stock_lines": {
      "post": {
        "tags": [
          "ffl_integrations"
        ],
        "summary": "The loose-stock lines of a GunBroker order and where in the store each can be",
        "description": "taken from, for the \"where did these come from?\" step of Dispose.\n\n**Auth (derived from code):** Roles: Sales User / Sales Manager / Stock Manager / System Manager\n\nSource: `apps/ffl_integrations/ffl_integrations/gunbroker/fulfillment.py:1185`",
        "operationId": "ffl_integrations.gunbroker.fulfillment.get_dispose_stock_lines",
        "responses": {
          "200": {
            "description": "[{line, item_code, item_name, qty, locations: [{location, label, qty}], unassigned, chosen}] -- one per item-level line (ammunition, optics, parts). ``line`` is the GunBroker item id the dispose call keys its picks by; ``chosen`` is the sole place the item can only have come from (exactly one holds it, none is unassigned).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "array"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "gunbroker_order": {
                    "type": "string",
                    "description": "GunBroker Order name."
                  }
                },
                "required": [
                  "gunbroker_order"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_integrations.gunbroker.fulfillment.list_pending_gb_orders": {
      "post": {
        "tags": [
          "ffl_integrations"
        ],
        "summary": "Rows for the Pending Order page: GunBroker orders still needing work.",
        "description": "Shaped to match ffl_core.api.manual_order.list_pending_dispositions so the\npage renders three sources uniformly; these carry source=\"gunbroker\".\n\nAn order stays listed until its tracking number has been written back to\nGunBroker — which is later than a web order leaves, on purpose: the store\nbuys this label, so \"disposed\" is the middle of the job here, not the end.\n\n**Auth (derived from code):** Roles: Sales User / Sales Manager / Stock Manager / System Manager\n\n**Permissions:** Counter roles.\n\nSource: `apps/ffl_integrations/ffl_integrations/gunbroker/fulfillment.py:146`",
        "operationId": "ffl_integrations.gunbroker.fulfillment.list_pending_gb_orders",
        "responses": {
          "200": {
            "description": "Pending-order cards (source=\"gunbroker\"), shaped like list_pending_dispositions rows.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "array"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        }
      }
    },
    "/api/method/ffl_integrations.gunbroker.fulfillment.mark_gb_unit_refunded": {
      "post": {
        "tags": [
          "ffl_integrations"
        ],
        "summary": "Mark one unit of a model-level order as refunded on GunBroker.",
        "description": "For an oversold order: the buyer paid for N, only N-1 guns exist, and the\nbuyer is refunded for the missing one on GunBroker's side. A unit marked\nrefunded stops counting as a claim, gets no gun, no bound-book entry and no\ninvoice line; the seller fee is still accrued on the whole GunBroker line,\nbecause GunBroker does not reduce it for a refund. The invoice then no longer\nagrees with what GunBroker charged and stays in Draft for a person to check\nthe refund against the statement.\n\nMarking a unit that already has a gun releases the gun (if this order holds\nit). ``refunded=0`` undoes the mark.\n\n**Auth (derived from code):** Roles: Sales User / Sales Manager / Stock Manager / System Manager\n\n**Permissions:** Counter roles.\n\nSource: `apps/ffl_integrations/ffl_integrations/gunbroker/fulfillment.py:1136`",
        "operationId": "ffl_integrations.gunbroker.fulfillment.mark_gb_unit_refunded",
        "responses": {
          "200": {
            "description": "{ok, refunded, row: the refreshed Pending Order card}.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "gunbroker_order": {
                    "type": "string",
                    "description": "GunBroker Order name (must be Pending Fulfillment)."
                  },
                  "row_name": {
                    "type": "string",
                    "description": "The unit, as the card gives it: ``<gunbroker item id>:<unit number>``."
                  },
                  "refunded": {
                    "type": "integer",
                    "description": "1 to mark (default), 0 to undo.",
                    "default": 1
                  }
                },
                "required": [
                  "gunbroker_order",
                  "row_name"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_integrations.gunbroker.fulfillment.mark_payment_received": {
      "post": {
        "tags": [
          "ffl_integrations"
        ],
        "summary": "Record that a GunBroker buyer's payment has been banked.",
        "description": "This is the fact the Dispose gate opens on, and it is deliberately not\nGunBroker's own \"payment received\" flag: that flag is a click on their\nwebsite, and a gun must not leave the building on the strength of it.\n\nNo Payment Entry is created here. GunBroker orders are paid before they are\ninvoiced, and the invoice does not exist until the guns are disposed — so\nthere is nothing to book the receipt against yet. The values recorded here\nare replayed onto a Payment Entry the moment the invoice is raised, against\nthe account of the Mode of Payment recorded.\n\n**Auth (derived from code):** Roles: Sales User / Sales Manager / Stock Manager / System Manager\n\n**Permissions:** Counter roles.\n\nSource: `apps/ffl_integrations/ffl_integrations/gunbroker/fulfillment.py:467`",
        "operationId": "ffl_integrations.gunbroker.fulfillment.mark_payment_received",
        "responses": {
          "200": {
            "description": "{ok, mode_of_payment, amount, received_on, difference}.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "gunbroker_order": {
                    "type": "string",
                    "description": "GunBroker Order name."
                  },
                  "mode_of_payment": {
                    "type": "string",
                    "description": "\"GunBroker Check\" (also accepted as \"Check/Money Order\"), \"GunBroker Card\" (GunBroker's own checkout; refused while no gateway is connected), or a tender the store took directly: \"Credit Card\" (charged on the Virtual Terminal), \"Zelle\" or \"ACH\". Cash is refused: the receipt is dated the day the invoice is raised, so cash would sit in the drawer with nothing on the books for it."
                  },
                  "amount": {
                    "type": "number",
                    "description": "What was actually banked, which is not always what was owed."
                  },
                  "reference_no": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "description": "Cheque / money-order number, Zelle or ACH confirmation, or card approval code. Required for every mode but GunBroker Card — without it the deposit cannot be traced on a bank statement."
                  },
                  "received_on": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "description": "The day it went INTO the bank, not the day it arrived in the post. Defaults to today."
                  },
                  "replace_posted_receipt": {
                    "type": "integer",
                    "description": "Record over an order whose receipt has already been posted. Refused without it, and alerted on with it.",
                    "default": 0
                  }
                },
                "required": [
                  "gunbroker_order",
                  "mode_of_payment",
                  "amount"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_integrations.gunbroker.fulfillment.push_gb_shipment": {
      "post": {
        "tags": [
          "ffl_integrations"
        ],
        "summary": "Push a paid GunBroker order to ShipStation (the Pending Order Ship action).",
        "description": "Same as a counter or web order: Ship does not wait for Dispose. Before\nDispose there is no invoice, so the shipment is built off the order itself\nand its id is kept on the order; revenue copies it onto the invoice when\nDispose raises one, which is where the tracking write-back reads it. After\nDispose this is the invoice's own push_shipment.\n\nThe gates are Dispose's (paid, FFL received, every unit named, no\nunresolved line) plus a valid destination, so nothing reaches ShipStation\nthat Dispose would then refuse. A C&R licence is only verified in the\nDispose dialog, so a C&R order not yet verified must Dispose first.\nTracking still goes back to GunBroker only after Dispose.\n\n**Auth (derived from code):** Roles: Sales User / Sales Manager / Stock Manager / System Manager\n\n**Permissions:** Counter roles.\n\nSource: `apps/ffl_integrations/ffl_integrations/gunbroker/fulfillment.py:1802`",
        "operationId": "ffl_integrations.gunbroker.fulfillment.push_gb_shipment",
        "responses": {
          "200": {
            "description": "{ok, shipstation_order_id} — plus already: True when it was pushed before.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "gunbroker_order": {
                    "type": "string",
                    "description": "GunBroker Order name."
                  }
                },
                "required": [
                  "gunbroker_order"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_integrations.gunbroker.fulfillment.push_tracking_now": {
      "post": {
        "tags": [
          "ffl_integrations"
        ],
        "summary": "Write this order's tracking number back to GunBroker now.",
        "description": "The scheduled poll does this on its own every ten minutes; this is for the\noperator who has just bought the label and wants the buyer to see it.\n\n**Auth (derived from code):** Roles: Sales User / Sales Manager / Stock Manager / System Manager\n\n**Permissions:** Counter roles.\n\nSource: `apps/ffl_integrations/ffl_integrations/gunbroker/fulfillment.py:1727`",
        "operationId": "ffl_integrations.gunbroker.fulfillment.push_tracking_now",
        "responses": {
          "200": {
            "description": "{ok, tracking_number, carrier, steps} — or {ok: False, reason} when there is no live label yet.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "gunbroker_order": {
                    "type": "string",
                    "description": "GunBroker Order name (disposed, with a ShipStation shipment against its invoice)."
                  }
                },
                "required": [
                  "gunbroker_order"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_integrations.gunbroker.fulfillment.reserved_gb_serials": {
      "post": {
        "tags": [
          "ffl_integrations"
        ],
        "summary": "GunBroker hold registry for one Item's serials — the DISPLAY half.",
        "description": "**Auth (derived from code):** Role-filtered: callers without Roles Sales User / Sales Manager / Stock Manager / System Manager receive an EMPTY result instead of an error.\n\n**Permissions:** Canonical shipping roles, matching the counter and web registries this merges with — it names which regulated serials sit on which order. A caller WITHOUT the role gets an empty ``{}`` back silently, so an empty result from THIS function is not proof of \"no holds\".\n\nSource: `apps/ffl_integrations/ffl_integrations/gunbroker/fulfillment.py:55`",
        "operationId": "ffl_integrations.gunbroker.fulfillment.reserved_gb_serials",
        "responses": {
          "200": {
            "description": "``{serial: {source, ref, kind, tooltip, url}}`` — only held serials appear. ``kind`` is ``gb_sold`` for a gun with a GunBroker order against it, or ``gb_sold_unknown`` for one the sweep believes was sold there while the order has not arrived yet.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "item_code": {
                    "type": "string",
                    "description": "Item whose serials to check."
                  }
                },
                "required": [
                  "item_code"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_integrations.gunbroker.revenue.create_gb_invoice_now": {
      "post": {
        "tags": [
          "ffl_integrations"
        ],
        "summary": "Retry the revenue booking for a disposed GunBroker order.",
        "description": "For an order whose invoice failed, stopped in Draft, or was posted without\nits receipt (the payment was recorded after the guns had already shipped).\n\n**Auth (derived from code):** Roles: Sales User / Sales Manager / Stock Manager / System Manager\n\n**Permissions:** Counter roles (the same gate as the fulfillment actions).\n\nSource: `apps/ffl_integrations/ffl_integrations/gunbroker/revenue.py:217`",
        "operationId": "ffl_integrations.gunbroker.revenue.create_gb_invoice_now",
        "responses": {
          "200": {
            "description": "The booking result from create_sales_invoice_for_gb_order.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "gunbroker_order": {
                    "type": "string",
                    "description": "GunBroker Order name (must be Transferred)."
                  }
                },
                "required": [
                  "gunbroker_order"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_integrations.gunbroker.webhooks.fixed_price_listing_failed": {
      "post": {
        "tags": [
          "webhooks"
        ],
        "summary": "GunBroker FixedPriceListingFailed webhook: a listing failed, so record why and re-check the gun.",
        "description": "**Auth (derived from code):** Guest — no session; the endpoint verifies the caller itself (HMAC signature, HTTP Basic credentials or a one-time token).\n\n**Payload:** GunBroker's ``{ItemTitle, ItemID, SKU, Quantity, \"Error Message\"}`` JSON. The item number, SKU and error text are read; the text is stored as plain text on the gun's (or item's) GunBroker sync error.\n\nSource: `apps/ffl_integrations/ffl_integrations/gunbroker/webhooks.py:446`",
        "operationId": "ffl_integrations.gunbroker.webhooks.fixed_price_listing_failed",
        "responses": {
          "200": {
            "description": "200 ``{ok: true}`` once accepted, including when no gun matches. 401 on bad credentials, identical to the other GunBroker webhook endpoints.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "security": []
      }
    },
    "/api/method/ffl_integrations.gunbroker.webhooks.items_sold": {
      "post": {
        "tags": [
          "webhooks"
        ],
        "summary": "GunBroker ItemsSold webhook: an item sold, so pull the order now.",
        "description": "**Auth (derived from code):** Guest — no session; the endpoint verifies the caller itself (HMAC signature, HTTP Basic credentials or a one-time token).\n\n**Payload:** GunBroker's Order JSON. Only the order number is read; the order is then fetched from the GunBroker API by the order sync. The buyer details in the body are not stored or logged.\n\nSource: `apps/ffl_integrations/ffl_integrations/gunbroker/webhooks.py:382`",
        "operationId": "ffl_integrations.gunbroker.webhooks.items_sold",
        "responses": {
          "200": {
            "description": "200 ``{ok: true}`` once accepted, including when nothing could be matched. 401 when the HTTP Basic credentials are missing or wrong, word for word the same as when GunBroker is switched off or the webhook credentials are not set on this site.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "security": []
      }
    },
    "/api/method/ffl_integrations.gunbroker.webhooks.items_unsold_not_relisted": {
      "post": {
        "tags": [
          "webhooks"
        ],
        "summary": "GunBroker ItemsUnsoldNotRelisted webhook: a listing ended with no sale, so re-check the gun.",
        "description": "**Auth (derived from code):** Guest — no session; the endpoint verifies the caller itself (HMAC signature, HTTP Basic credentials or a one-time token).\n\n**Payload:** GunBroker's Item JSON. Only the item number and SKU are read.\n\nSource: `apps/ffl_integrations/ffl_integrations/gunbroker/webhooks.py:432`",
        "operationId": "ffl_integrations.gunbroker.webhooks.items_unsold_not_relisted",
        "responses": {
          "200": {
            "description": "200 ``{ok: true}`` once accepted, including when no gun matches. 401 on bad credentials, identical to the other GunBroker webhook endpoints.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "security": []
      }
    },
    "/api/method/ffl_integrations.gunbroker.webhooks.order_status_update": {
      "post": {
        "tags": [
          "webhooks"
        ],
        "summary": "GunBroker OrderStatusUpdate webhook: an order changed, so pull it now.",
        "description": "**Auth (derived from code):** Guest — no session; the endpoint verifies the caller itself (HMAC signature, HTTP Basic credentials or a one-time token).\n\n**Payload:** GunBroker's order-status JSON (OrderID and the milestone dates). Only the order number is read.\n\nSource: `apps/ffl_integrations/ffl_integrations/gunbroker/webhooks.py:400`",
        "operationId": "ffl_integrations.gunbroker.webhooks.order_status_update",
        "responses": {
          "200": {
            "description": "200 ``{ok: true}`` once accepted. 401 on bad credentials, identical to the other GunBroker webhook endpoints.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "security": []
      }
    },
    "/api/method/ffl_integrations.gunbroker.webhooks.winning_bid_received": {
      "post": {
        "tags": [
          "webhooks"
        ],
        "summary": "GunBroker WinningBidReceived webhook: an auction took a bid, so lock the gun now.",
        "description": "**Auth (derived from code):** Guest — no session; the endpoint verifies the caller itself (HMAC signature, HTTP Basic credentials or a one-time token).\n\n**Payload:** GunBroker's ``{item, currentBid}`` JSON. The item number, SKU, bid count, current bid and ending time are read; the gun is found by SKU, then item number.\n\nSource: `apps/ffl_integrations/ffl_integrations/gunbroker/webhooks.py:415`",
        "operationId": "ffl_integrations.gunbroker.webhooks.winning_bid_received",
        "responses": {
          "200": {
            "description": "200 ``{ok: true}`` once accepted; a gun that cannot be matched falls back to a full auction watch. 401 on bad credentials, identical to the other GunBroker webhook endpoints.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "security": []
      }
    },
    "/api/method/ffl_integrations.payments.api.cancel_gb_order_charge": {
      "post": {
        "tags": [
          "ffl_integrations"
        ],
        "summary": "Cancel an in-flight keyed card charge on a GunBroker order (race-safe).",
        "description": "A cancel that races an approval records the approval instead.\n\n**Auth (derived from code):** Roles: Sales User / Sales Manager / System Manager\n\n**Permissions:** POS charge roles (_check_perm).\n\nSource: `apps/ffl_integrations/ffl_integrations/payments/api.py:1479`",
        "operationId": "ffl_integrations.payments.api.cancel_gb_order_charge",
        "responses": {
          "200": {
            "description": "{ok: True, status: \"CANCELED\"} — or the settled approval with reconciled=True.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "gunbroker_order": {
                    "type": "string",
                    "description": "The GunBroker Order being charged."
                  },
                  "instruction_id": {
                    "type": "string",
                    "description": "The handle to cancel."
                  }
                },
                "required": [
                  "gunbroker_order",
                  "instruction_id"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_integrations.payments.api.cancel_pos_charge": {
      "post": {
        "tags": [
          "ffl_integrations"
        ],
        "summary": "Cancel an in-flight card charge (race-safe).",
        "description": "If the cancel RACES an approval (card just captured), the capture is\nreconciled instead of stranding it / letting a retry double-charge.\n\n**Auth (derived from code):** Roles: Sales User / Sales Manager / System Manager\n\n**Permissions:** POS charge roles (_check_perm).\n\nSource: `apps/ffl_integrations/ffl_integrations/payments/api.py:905`",
        "operationId": "ffl_integrations.payments.api.cancel_pos_charge",
        "responses": {
          "200": {
            "description": "{ok: True, status: \"CANCELED\"} — or the reconciled settle result when the approval won the race.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "invoice_name": {
                    "type": "string",
                    "description": "POS Invoice being tendered."
                  },
                  "instruction_id": {
                    "type": "string",
                    "description": "The charge handle to cancel."
                  }
                },
                "required": [
                  "invoice_name",
                  "instruction_id"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_integrations.payments.api.cancel_sales_invoice_charge": {
      "post": {
        "tags": [
          "ffl_integrations"
        ],
        "summary": "Cancel an in-flight terminal charge on a Sales Invoice (race-safe).",
        "description": "A cancel that races an approval settles the approval instead — the card\nwas charged, so it is recorded and booked, never stranded.\n\n**Auth (derived from code):** Roles: Sales User / Sales Manager / System Manager\n\n**Permissions:** POS charge roles (_check_perm).\n\nSource: `apps/ffl_integrations/ffl_integrations/payments/api.py:1278`",
        "operationId": "ffl_integrations.payments.api.cancel_sales_invoice_charge",
        "responses": {
          "200": {
            "description": "{ok: True, status: \"CANCELED\"} — or the settled approval with reconciled=True when the approval won the race.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "sales_invoice": {
                    "type": "string",
                    "description": "The Sales Invoice being charged."
                  },
                  "instruction_id": {
                    "type": "string",
                    "description": "The instruction to cancel."
                  }
                },
                "required": [
                  "sales_invoice",
                  "instruction_id"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_integrations.payments.api.card_tender_mode": {
      "post": {
        "tags": [
          "ffl_integrations"
        ],
        "summary": "Whether a Credit Card tender must go through the counter terminal.",
        "description": "Read-only. With a card processor switched on, configured and holding a\ndevice, a card is charged on the terminal (charge_pos_invoice); otherwise a\nCredit Card row is a plain tender typed from a standalone terminal.\n\n**Auth (derived from code):** Roles: Sales User / Sales Manager / System Manager\n\nSource: `apps/ffl_integrations/ffl_integrations/payments/api.py:647`",
        "operationId": "ffl_integrations.payments.api.card_tender_mode",
        "responses": {
          "200": {
            "description": "{\"integrated\": bool, \"readers\": [names]} — readers: the card readers switched on now, one of which a terminal charge must name ([] = the processor's one device, name none). The counter reads it again after a charge naming a reader is refused.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        }
      }
    },
    "/api/method/ffl_integrations.payments.api.charge_gb_order": {
      "post": {
        "tags": [
          "ffl_integrations"
        ],
        "summary": "Start a keyed card charge (the processor's payment page) for a GunBroker order.",
        "description": "Pending Order → Record Payment on a GunBroker order that has not been paid. The\nfrontend polls it with poll_gb_order_charge(); the approval is recorded as the\norder's payment, which opens Dispose. Reuses an in-flight charge rather than\ncharging twice.\n\n**Auth (derived from code):** Roles: Sales User / Sales Manager / System Manager\n\n**Permissions:** POS charge roles (_check_perm); keying a card in needs a manager.\n\nSource: `apps/ffl_integrations/ffl_integrations/payments/api.py:1363`",
        "operationId": "ffl_integrations.payments.api.charge_gb_order",
        "responses": {
          "200": {
            "description": "{ok, instruction_id, status, amount, keyed_url}; {\"skip\": True} when no card processor is switched on and configured; an earlier approval found unrecorded comes back settled with already=True.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "gunbroker_order": {
                    "type": "string",
                    "description": "GunBroker Order awaiting payment."
                  },
                  "amount": {
                    "description": "Charge amount, at most the order total (blank = the order total)."
                  }
                },
                "required": [
                  "gunbroker_order"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_integrations.payments.api.charge_pos_invoice": {
      "post": {
        "tags": [
          "ffl_integrations"
        ],
        "summary": "Start a card charge on the card processor's terminal for a POS invoice.",
        "description": "Starts the charge on the active processor's card device; the frontend then\npolls poll_pos_charge() until the terminal returns. Reuses an in-flight\ncharge rather than double-charging.\n\n**Auth (derived from code):** Roles: Sales User / Sales Manager / System Manager\n\n**Permissions:** POS charge roles (_check_perm).\n\nSource: `apps/ffl_integrations/ffl_integrations/payments/api.py:668`",
        "operationId": "ffl_integrations.payments.api.charge_pos_invoice",
        "responses": {
          "200": {
            "description": "{ok, instruction_id, reader, status, amount} — reader: the card reader the charge is on (a charge already in flight on this invoice keeps its own; None when no reader is named) — plus keyed_url (the payment page to open) for a keyed charge — or {\"skip\": True} when no card processor is switched on and configured. The poll that settles an approval then adds card_saved / save_message.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "invoice_name": {
                    "type": "string",
                    "description": "POS Invoice being tendered."
                  },
                  "terminal": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "description": "Optional terminal id; defaults to the configured one."
                  },
                  "amount": {
                    "description": "Optional charge amount; defaults to the card-tender target."
                  },
                  "description": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "description": "Optional statement descriptor."
                  },
                  "save_card": {
                    "description": "1 to keep the card for later charges (card on file): refused unless saving is switched on, the processor can keep cards and the invoice customer has signed the card-on-file authorization.",
                    "default": 0
                  },
                  "keyed": {
                    "description": "1 to key the card number in on the processor's payment page instead of the terminal (managers only; not with save_card).",
                    "default": 0
                  },
                  "reader": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "description": "This computer's card reader (its name). Required when the store lists card readers (refused when it is missing, unknown or switched off); ignored for a keyed charge. Without listed readers, leave it out."
                  }
                },
                "required": [
                  "invoice_name"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_integrations.payments.api.charge_sales_invoice": {
      "post": {
        "tags": [
          "ffl_integrations"
        ],
        "summary": "Start a card charge on the card processor's terminal against a counter Sales Invoice.",
        "description": "The counter's card tender for an on-account order (Create Order right\nafter the order books; Pending Order → Record Payment for a balance).\nStarts a charge on the active processor's card device; the frontend polls it with\npoll_sales_invoice_charge(); the approval books a Payment Entry. Reuses\nan in-flight instruction rather than double-charging, and never starts\none while an earlier approval on this invoice is unrecorded.\n\n**Auth (derived from code):** Roles: Sales User / Sales Manager / System Manager\n\n**Permissions:** POS charge roles (_check_perm).\n\nSource: `apps/ffl_integrations/ffl_integrations/payments/api.py:1115`",
        "operationId": "ffl_integrations.payments.api.charge_sales_invoice",
        "responses": {
          "200": {
            "description": "{ok, instruction_id, reader, status, amount} — reader: the card reader the charge is on (a charge already in flight on this invoice keeps its own; None when no reader is named) — plus keyed_url (the payment page to open) for a keyed charge — {\"skip\": True} when no card processor is switched on and configured; an earlier approval found unrecorded comes back settled with already=True. The poll that settles an approval then adds card_saved / save_message.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "sales_invoice": {
                    "type": "string",
                    "description": "Submitted Sales Invoice with an outstanding balance."
                  },
                  "amount": {
                    "description": "Charge amount, at most the outstanding balance (blank = the whole balance; less = a deposit)."
                  },
                  "terminal": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "description": "Optional terminal id; defaults to the configured one."
                  },
                  "save_card": {
                    "description": "1 to keep the card for later charges (card on file): refused unless saving is switched on, the processor can keep cards and the invoice customer has signed the card-on-file authorization.",
                    "default": 0
                  },
                  "keyed": {
                    "description": "1 to key the card number in on the processor's payment page instead of the terminal (managers only; not with save_card).",
                    "default": 0
                  },
                  "reader": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "description": "This computer's card reader (its name). Required when the store lists card readers (refused when it is missing, unknown or switched off); ignored for a keyed charge. Without listed readers, leave it out."
                  }
                },
                "required": [
                  "sales_invoice"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_integrations.payments.api.confirm_out_of_band_refund": {
      "post": {
        "tags": [
          "ffl_integrations"
        ],
        "summary": "Record that a gateway-charged sale's refund was issued in the card processor's portal.",
        "description": "The manager-level exit for the switched-off refund guard. Deliberately its\nown field plus a timeline entry — never the tender row's ``reference_no``,\nwhich the standalone-terminal flow collects for a different purpose and\nwhich therefore cannot double as this guard's evidence (a guard whose\nevidence another rule force-collects clears itself).\n\n**Auth (derived from code):** Roles: Sales Manager / System Manager\n\n**Permissions:** Manager role (_check_manager).\n\nSource: `apps/ffl_integrations/ffl_integrations/payments/api.py:2605`",
        "operationId": "ffl_integrations.payments.api.confirm_out_of_band_refund",
        "responses": {
          "200": {
            "description": "{ok: True, invoice, portal_reference}.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "return_invoice_name": {
                    "type": "string",
                    "description": "The POS RETURN invoice being confirmed."
                  },
                  "portal_reference": {
                    "type": "string",
                    "description": "The refund's reference from the processor's portal."
                  },
                  "reason": {
                    "type": "string",
                    "description": "Why the refund went out of band (audited, mandatory)."
                  }
                },
                "required": [
                  "return_invoice_name",
                  "portal_reference",
                  "reason"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_integrations.payments.api.list_terminals": {
      "post": {
        "tags": [
          "ffl_integrations"
        ],
        "summary": "List the terminals the active card processor's credentials may use (connectivity smoke test).",
        "description": "A zero-risk connectivity + pairing check (Payroc: the authenticate\nresponse's allowedTerminals).\n\n**Auth (derived from code):** Roles: Sales Manager / System Manager\n\n**Permissions:** Manager role.\n\nSource: `apps/ffl_integrations/ffl_integrations/payments/api.py:1523`",
        "operationId": "ffl_integrations.payments.api.list_terminals",
        "responses": {
          "200": {
            "description": "The processor's own answer, {\"error\": <body>} on a refusal, or {\"skip\": True} when no card processor is switched on and configured.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        }
      }
    },
    "/api/method/ffl_integrations.payments.api.poll_gb_order_charge": {
      "post": {
        "tags": [
          "ffl_integrations"
        ],
        "summary": "Poll a keyed card charge started by charge_gb_order once.",
        "description": "**Auth (derived from code):** Roles: Sales User / Sales Manager / System Manager\n\n**Permissions:** POS charge roles (_check_perm).\n\nSource: `apps/ffl_integrations/ffl_integrations/payments/api.py:1454`",
        "operationId": "ffl_integrations.payments.api.poll_gb_order_charge",
        "responses": {
          "200": {
            "description": "{ok: True, unique_reference, approval_code, amount, paid} on approval (the payment is recorded on the order); {ok: False, status: \"IN_PROGRESS\"} while pending; {ok: False, status, error} on decline / cancel.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "gunbroker_order": {
                    "type": "string",
                    "description": "The GunBroker Order being charged."
                  },
                  "instruction_id": {
                    "type": "string",
                    "description": "The handle returned by charge_gb_order."
                  }
                },
                "required": [
                  "gunbroker_order",
                  "instruction_id"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_integrations.payments.api.poll_pos_charge": {
      "post": {
        "tags": [
          "ffl_integrations"
        ],
        "summary": "Poll a card charge once, on the processor that started it.",
        "description": "In progress → {ok: False} (frontend loops). Finished → verify full\napproval, stamp the reference on the invoice.\n\n**Auth (derived from code):** Roles: Sales User / Sales Manager / System Manager\n\n**Permissions:** POS charge roles (_check_perm).\n\nSource: `apps/ffl_integrations/ffl_integrations/payments/api.py:855`",
        "operationId": "ffl_integrations.payments.api.poll_pos_charge",
        "responses": {
          "200": {
            "description": "{ok: True, ...settled details} on completion; {ok: False, status: \"IN_PROGRESS\"} while pending; {ok: False, status, error} on terminal failure.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "invoice_name": {
                    "type": "string",
                    "description": "POS Invoice being tendered."
                  },
                  "instruction_id": {
                    "type": "string",
                    "description": "The charge handle returned by charge_pos_invoice."
                  },
                  "expected_amount": {
                    "description": "Optional approval-amount check."
                  }
                },
                "required": [
                  "invoice_name",
                  "instruction_id"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_integrations.payments.api.poll_sales_invoice_charge": {
      "post": {
        "tags": [
          "ffl_integrations"
        ],
        "summary": "Poll a terminal charge started by charge_sales_invoice once.",
        "description": "IN_PROGRESS → {ok: False} (frontend loops). On approval the record goes\nCHARGED and a Payment Entry books against the invoice; the answer carries\nthe new balance.\n\n**Auth (derived from code):** Roles: Sales User / Sales Manager / System Manager\n\n**Permissions:** POS charge roles (_check_perm).\n\nSource: `apps/ffl_integrations/ffl_integrations/payments/api.py:1247`",
        "operationId": "ffl_integrations.payments.api.poll_sales_invoice_charge",
        "responses": {
          "200": {
            "description": "{ok: True, unique_reference, approval_code, amount, payment_entry, outstanding, paid} on approval; {ok: False, status: \"IN_PROGRESS\"} while pending; {ok: False, status, error} on decline / cancel.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "sales_invoice": {
                    "type": "string",
                    "description": "The Sales Invoice being charged."
                  },
                  "instruction_id": {
                    "type": "string",
                    "description": "The instruction returned by charge_sales_invoice."
                  }
                },
                "required": [
                  "sales_invoice",
                  "instruction_id"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_integrations.payments.api.refund_pos_invoice": {
      "post": {
        "tags": [
          "ffl_integrations"
        ],
        "summary": "Refund a POS return's card portion to the original card(s).",
        "description": "Referenced refund of the Credit Card portion of a POS RETURN invoice,\nsent to the processor that took each original charge. Firearm returns\nare blocked (bound-book reversal is a separate project). Multi-card\noriginals refund across rows within per-original-card caps.\n\n**Auth (derived from code):** Roles: Sales Manager / System Manager\n\n**Permissions:** Manager-gated refund roles (gate at entry).\n\nSource: `apps/ffl_integrations/ffl_integrations/payments/api.py:1860`",
        "operationId": "ffl_integrations.payments.api.refund_pos_invoice",
        "responses": {
          "200": {
            "description": "{ok: True, refund_reference, amount, original}; {\"skip\": True} when no card processor is switched on and configured, or the original never took gateway money.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "return_invoice_name": {
                    "type": "string",
                    "description": "The POS RETURN invoice."
                  },
                  "reason": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "description": "Optional audit reason."
                  }
                },
                "required": [
                  "return_invoice_name"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_integrations.payments.api.unlock_refund_lock": {
      "post": {
        "tags": [
          "ffl_integrations"
        ],
        "summary": "Manager unlock for a return whose automatic card refund armed the",
        "description": "UNKNOWN-OUTCOME re-refund lock (the amplifier: the\nlock had no product-side unlock, so a locked return died in bench\nconsole).\n\nONLY ``UNKNOWN-OUTCOME`` unlocks — zero slices booked, so a full-amount\nretry is exactly the original entitlement. A ``PARTIAL:*`` sentinel is\nthe ONE record of how much this return already pushed back; clearing it\nre-arms a full-amount retry that the per-ORIGINAL-card caps cannot bound\n(an original with headroom would refund the booked slices again).\nIts residue goes to back-office manual processing.\nA real refund reference means the refund COMPLETED and never unlocks.\n\nThe unlock is an attestation, not a reconciliation: the gateway may\nactually have refunded (rows still show headroom), so the manager must\nverify in the processor's portal FIRST — the reason is required and the whole\naction lands in the document timeline (who/when/why/previous lock),\nmirroring manager_override_4473's audit posture.\n\n**Auth (derived from code):** Roles: Sales Manager / System Manager\n\n**Permissions:** Manager gate (roles per the derived Auth line) + required reason — the reason must record what was verified in the processor's portal.\n\nSource: `apps/ffl_integrations/ffl_integrations/payments/api.py:2243`",
        "operationId": "ffl_integrations.payments.api.unlock_refund_lock",
        "responses": {
          "200": {
            "description": "{ok: True, cleared: <previous lock value>, invoice}.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "return_invoice_name": {
                    "type": "string",
                    "description": "The locked POS RETURN invoice."
                  },
                  "reason": {
                    "type": "string",
                    "description": "Required attestation — what the manager verified in the card processor's portal."
                  }
                },
                "required": [
                  "return_invoice_name",
                  "reason"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_integrations.payments.api.void_pos_invoice": {
      "post": {
        "tags": [
          "ffl_integrations"
        ],
        "summary": "Reverse an unsettled card charge (back-office; per-card on multi-card).",
        "description": "Books the gateway reversal on the processor that took the charge (Payroc\nhas no /void: it reverses). Multi-card invoices void PER CARD: pass the\ncharge row's unique_reference when more than one live capture exists.\n\n**Auth (derived from code):** Roles: Sales Manager / System Manager\n\n**Permissions:** Refund/void roles (_check_refund_perm).\n\nSource: `apps/ffl_integrations/ffl_integrations/payments/api.py:1547`",
        "operationId": "ffl_integrations.payments.api.void_pos_invoice",
        "responses": {
          "200": {
            "description": "{ok: True, unique_reference, response}.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "invoice_name": {
                    "type": "string",
                    "description": "POS Invoice carrying the charge."
                  },
                  "reason": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "description": "Optional audit reason."
                  },
                  "unique_reference": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "description": "The specific charge row to void (required when several live captures exist)."
                  }
                },
                "required": [
                  "invoice_name"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_integrations.payments.hub.overview": {
      "post": {
        "tags": [
          "ffl_integrations"
        ],
        "summary": "Everything the payment-hub page renders, in one round trip.",
        "description": "``enabled`` is each processor's own ``enabled()`` (Payroc: ``single_flag``,\nraw ``tabSingles`` row, docfield default when absent) — the same defence the\nintegration gate uses, so a site that never saved the settings form reads ON,\nnot OFF.\n\n**Auth (derived from code):** Roles: System Manager\n\n**Permissions:** System Manager (mirrors Payroc Settings).\n\nSource: `apps/ffl_integrations/ffl_integrations/payments/hub.py:47`",
        "operationId": "ffl_integrations.payments.hub.overview",
        "responses": {
          "200": {
            "description": "{processors: [{code, label, kind, settings_doctype, mode_of_payment, enabled, ready, can_write, supports_card_on_file, health: [{label, at}]}], can_write, card_on_file: {enabled, template, can_write}}. ``ready`` is enabled AND credentials present — the switch can be on while the key is missing, and the card has to show that as its own state, not as \"working\".",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        }
      }
    },
    "/api/method/ffl_integrations.payments.hub.save_card_on_file": {
      "post": {
        "tags": [
          "ffl_integrations"
        ],
        "summary": "Switch \"Save this card\" on or off and pick the authorization customers sign first.",
        "description": "Through the real settings save, so the Single's rules apply: switching on needs an active\nPer customer agreement template.\n\n**Auth (derived from code):** Roles: System Manager\n\n**Permissions:** System Manager, plus the doc-level write check ``doc.save()`` runs.\n\nSource: `apps/ffl_integrations/ffl_integrations/payments/hub.py:92`",
        "operationId": "ffl_integrations.payments.hub.save_card_on_file",
        "responses": {
          "200": {
            "description": "{enabled: 0|1, template}.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "enabled": {
                    "description": "Truthy/falsy."
                  },
                  "template": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "description": "Agreement Template name (required to switch on)."
                  }
                },
                "required": [
                  "enabled"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_integrations.payments.hub.test_connection": {
      "post": {
        "tags": [
          "ffl_integrations"
        ],
        "summary": "Run the processor's read-only connection probe.",
        "description": "**Auth (derived from code):** Roles: System Manager\n\n**Permissions:** System Manager.\n\nSource: `apps/ffl_integrations/ffl_integrations/payments/hub.py:155`",
        "operationId": "ffl_integrations.payments.hub.test_connection",
        "responses": {
          "200": {
            "description": "{checks: [{label, ok, detail}]} — the shape the distributor hub renders, so the two pages share one mental model. ``ok`` is true, false, or null for \"not applicable\" (e.g. the switch is off, so nothing was probed — that is a state, not a failure).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "processor": {
                    "type": "string",
                    "description": "Registry code (e.g. ``\"payroc\"``)."
                  }
                },
                "required": [
                  "processor"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_integrations.payments.hub.toggle": {
      "post": {
        "tags": [
          "ffl_integrations"
        ],
        "summary": "Flip one processor's enable switch, through the real settings save.",
        "description": "Deliberately ``doc.save()``, not ``db_set``: the settings form makes the\ncredential fields mandatory while the switch is on (a store cannot arm a\nprocessor it holds no key for), and a hub that wrote the flag straight to\nthe table would be a side door around exactly that rule. Disabling never\ntrips it — credentials are only demanded while ``enabled`` stays 1. Only one\nprocessor takes cards at a time: switching one on while another is on is\nrefused (switch the other off first).\n\n**Auth (derived from code):** Roles: System Manager\n\n**Permissions:** System Manager, plus the doc-level write check ``doc.save()`` runs.\n\nSource: `apps/ffl_integrations/ffl_integrations/payments/hub.py:117`",
        "operationId": "ffl_integrations.payments.hub.toggle",
        "responses": {
          "200": {
            "description": "{code, enabled: 0|1}.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "processor": {
                    "type": "string",
                    "description": "Registry code (e.g. ``\"payroc\"``)."
                  },
                  "value": {
                    "description": "Truthy/falsy."
                  }
                },
                "required": [
                  "processor",
                  "value"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_integrations.payments.saved_cards.card_on_file_offer": {
      "post": {
        "tags": [
          "ffl_integrations"
        ],
        "summary": "Whether the counter may offer \"Save this card\" for this customer, and where the",
        "description": "customer stands with the authorization (the dialog polls it while the customer signs).\n\n**Auth (derived from code):** Roles: Sales User / Sales Manager / Accounts Manager / System Manager\n\nSource: `apps/ffl_integrations/ffl_integrations/payments/saved_cards.py:157`",
        "operationId": "ffl_integrations.payments.saved_cards.card_on_file_offer",
        "responses": {
          "200": {
            "description": "{offer: bool, reason: text when not offered, template, state: signed / expiring / expired / pending / missing, agreement: the copy the state comes from}.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "customer": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "description": "Customer name (document id)."
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_integrations.payments.saved_cards.charge_saved_card": {
      "post": {
        "tags": [
          "ffl_integrations"
        ],
        "summary": "Charge a customer's saved card against a submitted Sales Invoice (merchant-initiated).",
        "description": "Refused before the gateway when the card was removed or is another customer's, the invoice\nis not submitted or owes nothing, or the amount exceeds the balance. The approval books a\nPayment Entry exactly like a terminal payment; a decline books nothing. An answer that never\ncame back locks the invoice against another saved-card charge until a later call looks the\ncharge up at the gateway and records it.\n\n**Auth (derived from code):** Roles: Sales Manager / System Manager\n\nSource: `apps/ffl_integrations/ffl_integrations/payments/saved_cards.py:506`",
        "operationId": "ffl_integrations.payments.saved_cards.charge_saved_card",
        "responses": {
          "200": {
            "description": "{ok, status, unique_reference, approval_code, amount, payment_entry, outstanding, paid} on approval; {ok: False, status, error} on a decline; resolved=True when an earlier charge was settled instead of a new one.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "sales_invoice": {
                    "type": "string",
                    "description": "Submitted Sales Invoice with an outstanding balance."
                  },
                  "saved_card": {
                    "type": "string",
                    "description": "Saved Card name (must be Active and the invoice customer's)."
                  },
                  "amount": {
                    "description": "Amount to charge, at most the outstanding balance (blank = the whole balance)."
                  }
                },
                "required": [
                  "sales_invoice",
                  "saved_card"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_integrations.payments.saved_cards.list_saved_cards": {
      "post": {
        "tags": [
          "ffl_integrations"
        ],
        "summary": "A customer's active saved cards — summary, expiry, default — for the Customer form and the",
        "description": "Charge saved card picker. Never the token.\n\n**Auth (derived from code):** Roles: Sales User / Sales Manager / Accounts Manager / System Manager\n\nSource: `apps/ffl_integrations/ffl_integrations/payments/saved_cards.py:287`",
        "operationId": "ffl_integrations.payments.saved_cards.list_saved_cards",
        "responses": {
          "200": {
            "description": "{cards: [{name, card_summary, card_expiry, is_default, usage, saved_on}], can_manage: whether the caller may charge or remove them}.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "customer": {
                    "type": "string",
                    "description": "Customer name (document id)."
                  }
                },
                "required": [
                  "customer"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_integrations.payments.saved_cards.release_saved_card_charge": {
      "post": {
        "tags": [
          "ffl_integrations"
        ],
        "summary": "Close an unconfirmed saved-card charge as not charged, after a manager checked the",
        "description": "processor's portal. Looks it up once more first and records it if the gateway now has it;\nrefused while the charge is younger than the lookup grace period.\n\n**Auth (derived from code):** Roles: Sales Manager / System Manager\n\nSource: `apps/ffl_integrations/ffl_integrations/payments/saved_cards.py:457`",
        "operationId": "ffl_integrations.payments.saved_cards.release_saved_card_charge",
        "responses": {
          "200": {
            "description": "{ok: False, status: \"CANCELED\"} when released; the settle answer when the gateway had it.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "terminal_payment": {
                    "type": "string",
                    "description": "Card Terminal Payment of the saved-card charge (IN_PROGRESS)."
                  },
                  "reason": {
                    "type": "string",
                    "description": "What the manager checked (kept on the record)."
                  }
                },
                "required": [
                  "terminal_payment",
                  "reason"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_integrations.payments.saved_cards.remove_saved_card": {
      "post": {
        "tags": [
          "ffl_integrations"
        ],
        "summary": "Remove a saved card: the card processor forgets it, then the record turns Removed.",
        "description": "A gateway failure leaves the card Active and says so. A Removed card can never be charged.\nWhen the default card goes, the newest remaining card becomes the default.\n\n**Auth (derived from code):** Roles: Sales Manager / System Manager\n\nSource: `apps/ffl_integrations/ffl_integrations/payments/saved_cards.py:533`",
        "operationId": "ffl_integrations.payments.saved_cards.remove_saved_card",
        "responses": {
          "200": {
            "description": "{ok: True, status: \"Removed\"}.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "saved_card": {
                    "type": "string",
                    "description": "Saved Card name."
                  },
                  "reason": {
                    "type": "string",
                    "description": "Why it is removed (kept on the record)."
                  }
                },
                "required": [
                  "saved_card",
                  "reason"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_integrations.payments.si_reversal.card_charges": {
      "post": {
        "tags": [
          "ffl_integrations"
        ],
        "summary": "The card charges on a Sales Invoice that a manager can void or refund, for the form.",
        "description": "**Auth (derived from code):** Roles: Sales Manager / System Manager\n\nSource: `apps/ffl_integrations/ffl_integrations/payments/si_reversal.py:453`",
        "operationId": "ffl_integrations.payments.si_reversal.card_charges",
        "responses": {
          "200": {
            "description": "{charges: [{name, amount, refunded_amount, left, status, unique_reference, card_summary, locked, lock, can_void}], membership, return_blocked}.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "sales_invoice": {
                    "type": "string",
                    "description": "The Sales Invoice."
                  }
                },
                "required": [
                  "sales_invoice"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_integrations.payments.si_reversal.refund_sales_invoice_charge": {
      "post": {
        "tags": [
          "ffl_integrations"
        ],
        "summary": "Refund part or all of a card charge on a counter Sales Invoice to the card it came from.",
        "description": "Return: a credit note takes the amount back from the sale, pro rata over its lines and tax, and\na Pay Payment Entry settles it (only for invoices that never touched stock or the bound book;\nmembership lines once the membership has ended). Collect again: a Journal Entry puts the amount\nback on the invoice to be collected another way.\n\n**Auth (derived from code):** Roles: Sales Manager / System Manager\n\nSource: `apps/ffl_integrations/ffl_integrations/payments/si_reversal.py:332`",
        "operationId": "ffl_integrations.payments.si_reversal.refund_sales_invoice_charge",
        "responses": {
          "200": {
            "description": "{ok, amount, gateway_reference, entry_type, entry, credit_note, outstanding}.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "terminal_payment": {
                    "type": "string",
                    "description": "The Card Terminal Payment row of the charge."
                  },
                  "amount": {
                    "description": "How much to give back, at most what is left on the charge. A Return refunds the credit note's total, which can differ from this by a cent of rounding."
                  },
                  "refund_type": {
                    "type": "string",
                    "description": "\"Return\" or \"Collect again\"."
                  },
                  "reason": {
                    "type": "string",
                    "description": "Why (kept on the invoice timeline and the bookings)."
                  }
                },
                "required": [
                  "terminal_payment",
                  "amount",
                  "refund_type",
                  "reason"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_integrations.payments.si_reversal.resolve_card_reversal": {
      "post": {
        "tags": [
          "ffl_integrations"
        ],
        "summary": "Settle a void or refund the card processor never confirmed, after looking in its portal.",
        "description": "**Auth (derived from code):** Roles: Sales Manager / System Manager\n\nSource: `apps/ffl_integrations/ffl_integrations/payments/si_reversal.py:410`",
        "operationId": "ffl_integrations.payments.si_reversal.resolve_card_reversal",
        "responses": {
          "200": {
            "description": "{ok, booked, ...the booking when booked}.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "terminal_payment": {
                    "type": "string",
                    "description": "The locked Card Terminal Payment row."
                  },
                  "went_through": {
                    "description": "1 when the portal shows the void/refund happened (it is booked now, exactly as an approval would have been); 0 when it did not (the charge is unlocked, nothing is booked)."
                  },
                  "note": {
                    "type": "string",
                    "description": "What was checked in the portal."
                  },
                  "portal_reference": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "description": "The portal's reference for the void/refund (required when it went through)."
                  }
                },
                "required": [
                  "terminal_payment",
                  "went_through",
                  "note"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_integrations.payments.si_reversal.void_sales_invoice_charge": {
      "post": {
        "tags": [
          "ffl_integrations"
        ],
        "summary": "Void a card charge on a counter Sales Invoice: the processor reverses the whole capture",
        "description": "(before it settles) and the invoice owes the amount again.\n\nThe charge's Payment Entry is cancelled when it was posted today, settles only this charge and\nis not bank-cleared; otherwise a Journal Entry today books the reversal. Membership invoices\nare refunded instead (type Return).\n\n**Auth (derived from code):** Roles: Sales Manager / System Manager\n\nSource: `apps/ffl_integrations/ffl_integrations/payments/si_reversal.py:298`",
        "operationId": "ffl_integrations.payments.si_reversal.void_sales_invoice_charge",
        "responses": {
          "200": {
            "description": "{ok, status, entry_type, entry, outstanding}.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "terminal_payment": {
                    "type": "string",
                    "description": "The Card Terminal Payment row of the charge."
                  },
                  "reason": {
                    "type": "string",
                    "description": "Why (kept on the invoice timeline and the booking)."
                  }
                },
                "required": [
                  "terminal_payment",
                  "reason"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_integrations.payroc.api.cancel_pos_charge": {
      "post": {
        "tags": [
          "ffl_integrations"
        ],
        "summary": "Old path of ffl_integrations.payments.api.cancel_pos_charge (cancel an in-flight charge).",
        "description": "**Auth (derived from code):** Roles: Sales User / Sales Manager / System Manager\n\nSource: `apps/ffl_integrations/ffl_integrations/payroc/api.py:57`",
        "operationId": "ffl_integrations.payroc.api.cancel_pos_charge",
        "responses": {
          "200": {
            "description": "The new endpoint's answer.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "invoice_name": {
                    "type": "string",
                    "description": "POS Invoice being tendered."
                  },
                  "instruction_id": {
                    "type": "string",
                    "description": "The charge handle to cancel."
                  }
                },
                "required": [
                  "invoice_name",
                  "instruction_id"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_integrations.payroc.api.cancel_sales_invoice_charge": {
      "post": {
        "tags": [
          "ffl_integrations"
        ],
        "summary": "Old path of ffl_integrations.payments.api.cancel_sales_invoice_charge.",
        "description": "**Auth (derived from code):** Roles: Sales User / Sales Manager / System Manager\n\nSource: `apps/ffl_integrations/ffl_integrations/payroc/api.py:106`",
        "operationId": "ffl_integrations.payroc.api.cancel_sales_invoice_charge",
        "responses": {
          "200": {
            "description": "The new endpoint's answer.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "sales_invoice": {
                    "type": "string",
                    "description": "The Sales Invoice being charged."
                  },
                  "instruction_id": {
                    "type": "string",
                    "description": "The charge handle to cancel."
                  }
                },
                "required": [
                  "sales_invoice",
                  "instruction_id"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_integrations.payroc.api.charge_pos_invoice": {
      "post": {
        "tags": [
          "ffl_integrations"
        ],
        "summary": "Old path of ffl_integrations.payments.api.charge_pos_invoice (start a card charge).",
        "description": "**Auth (derived from code):** Roles: Sales User / Sales Manager / System Manager\n\nSource: `apps/ffl_integrations/ffl_integrations/payroc/api.py:20`",
        "operationId": "ffl_integrations.payroc.api.charge_pos_invoice",
        "responses": {
          "200": {
            "description": "The new endpoint's answer: {ok, instruction_id, reader, status, amount} or {\"skip\": True}.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "invoice_name": {
                    "type": "string",
                    "description": "POS Invoice being tendered."
                  },
                  "terminal": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "description": "Optional terminal id; defaults to the configured one."
                  },
                  "amount": {
                    "description": "Optional charge amount; defaults to the card-tender target."
                  },
                  "description": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "description": "Optional statement descriptor."
                  },
                  "reader": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "description": "The card reader to charge on (its name); required when the store lists card readers, as on the new endpoint."
                  }
                },
                "required": [
                  "invoice_name"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_integrations.payroc.api.charge_sales_invoice": {
      "post": {
        "tags": [
          "ffl_integrations"
        ],
        "summary": "Old path of ffl_integrations.payments.api.charge_sales_invoice (card charge on a counter order).",
        "description": "**Auth (derived from code):** Roles: Sales User / Sales Manager / System Manager\n\nSource: `apps/ffl_integrations/ffl_integrations/payroc/api.py:72`",
        "operationId": "ffl_integrations.payroc.api.charge_sales_invoice",
        "responses": {
          "200": {
            "description": "The new endpoint's answer.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "sales_invoice": {
                    "type": "string",
                    "description": "Submitted Sales Invoice with an outstanding balance."
                  },
                  "amount": {
                    "description": "Charge amount, at most the outstanding balance (blank = the whole balance)."
                  },
                  "terminal": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "description": "Optional terminal id; defaults to the configured one."
                  },
                  "reader": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "description": "The card reader to charge on (its name); required when the store lists card readers, as on the new endpoint."
                  }
                },
                "required": [
                  "sales_invoice"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_integrations.payroc.api.confirm_out_of_band_refund": {
      "post": {
        "tags": [
          "ffl_integrations"
        ],
        "summary": "Old path of ffl_integrations.payments.api.confirm_out_of_band_refund.",
        "description": "**Auth (derived from code):** Roles: Sales Manager / System Manager\n\nSource: `apps/ffl_integrations/ffl_integrations/payroc/api.py:179`",
        "operationId": "ffl_integrations.payroc.api.confirm_out_of_band_refund",
        "responses": {
          "200": {
            "description": "The new endpoint's answer.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "return_invoice_name": {
                    "type": "string",
                    "description": "The POS RETURN invoice being confirmed."
                  },
                  "portal_reference": {
                    "type": "string",
                    "description": "The refund's reference from the processor's portal."
                  },
                  "reason": {
                    "type": "string",
                    "description": "Why the refund went out of band (audited, mandatory)."
                  }
                },
                "required": [
                  "return_invoice_name",
                  "portal_reference",
                  "reason"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_integrations.payroc.api.discover_terminals": {
      "post": {
        "tags": [
          "ffl_integrations"
        ],
        "summary": "Old path of ffl_integrations.payments.api.list_terminals (connectivity smoke test).",
        "description": "**Auth (derived from code):** Roles: Sales Manager / System Manager\n\nSource: `apps/ffl_integrations/ffl_integrations/payroc/api.py:121`",
        "operationId": "ffl_integrations.payroc.api.discover_terminals",
        "responses": {
          "200": {
            "description": "The new endpoint's answer: the processor's terminal list, {\"error\": ...} or {\"skip\": True}.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        }
      }
    },
    "/api/method/ffl_integrations.payroc.api.poll_pos_charge": {
      "post": {
        "tags": [
          "ffl_integrations"
        ],
        "summary": "Old path of ffl_integrations.payments.api.poll_pos_charge (poll a card charge once).",
        "description": "**Auth (derived from code):** Roles: Sales User / Sales Manager / System Manager\n\nSource: `apps/ffl_integrations/ffl_integrations/payroc/api.py:41`",
        "operationId": "ffl_integrations.payroc.api.poll_pos_charge",
        "responses": {
          "200": {
            "description": "The new endpoint's answer.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "invoice_name": {
                    "type": "string",
                    "description": "POS Invoice being tendered."
                  },
                  "instruction_id": {
                    "type": "string",
                    "description": "The charge handle returned by charge_pos_invoice."
                  },
                  "expected_amount": {
                    "description": "Optional approval-amount check."
                  }
                },
                "required": [
                  "invoice_name",
                  "instruction_id"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_integrations.payroc.api.poll_sales_invoice_charge": {
      "post": {
        "tags": [
          "ffl_integrations"
        ],
        "summary": "Old path of ffl_integrations.payments.api.poll_sales_invoice_charge.",
        "description": "**Auth (derived from code):** Roles: Sales User / Sales Manager / System Manager\n\nSource: `apps/ffl_integrations/ffl_integrations/payroc/api.py:91`",
        "operationId": "ffl_integrations.payroc.api.poll_sales_invoice_charge",
        "responses": {
          "200": {
            "description": "The new endpoint's answer.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "sales_invoice": {
                    "type": "string",
                    "description": "The Sales Invoice being charged."
                  },
                  "instruction_id": {
                    "type": "string",
                    "description": "The charge handle returned by charge_sales_invoice."
                  }
                },
                "required": [
                  "sales_invoice",
                  "instruction_id"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_integrations.payroc.api.refund_pos_invoice": {
      "post": {
        "tags": [
          "ffl_integrations"
        ],
        "summary": "Old path of ffl_integrations.payments.api.refund_pos_invoice (refund a POS return's card portion).",
        "description": "**Auth (derived from code):** Roles: Sales Manager / System Manager\n\nSource: `apps/ffl_integrations/ffl_integrations/payroc/api.py:149`",
        "operationId": "ffl_integrations.payroc.api.refund_pos_invoice",
        "responses": {
          "200": {
            "description": "The new endpoint's answer.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "return_invoice_name": {
                    "type": "string",
                    "description": "The POS RETURN invoice."
                  },
                  "reason": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "description": "Optional audit reason."
                  }
                },
                "required": [
                  "return_invoice_name"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_integrations.payroc.api.unlock_refund_lock": {
      "post": {
        "tags": [
          "ffl_integrations"
        ],
        "summary": "Old path of ffl_integrations.payments.api.unlock_refund_lock (manager unlock of a refund lock).",
        "description": "**Auth (derived from code):** Roles: Sales Manager / System Manager\n\nSource: `apps/ffl_integrations/ffl_integrations/payroc/api.py:164`",
        "operationId": "ffl_integrations.payroc.api.unlock_refund_lock",
        "responses": {
          "200": {
            "description": "The new endpoint's answer.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "return_invoice_name": {
                    "type": "string",
                    "description": "The locked POS RETURN invoice."
                  },
                  "reason": {
                    "type": "string",
                    "description": "Required attestation — what the manager verified in the processor's portal."
                  }
                },
                "required": [
                  "return_invoice_name",
                  "reason"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_integrations.payroc.api.void_pos_invoice": {
      "post": {
        "tags": [
          "ffl_integrations"
        ],
        "summary": "Old path of ffl_integrations.payments.api.void_pos_invoice (reverse an unsettled charge).",
        "description": "**Auth (derived from code):** Roles: Sales Manager / System Manager\n\nSource: `apps/ffl_integrations/ffl_integrations/payroc/api.py:132`",
        "operationId": "ffl_integrations.payroc.api.void_pos_invoice",
        "responses": {
          "200": {
            "description": "The new endpoint's answer.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "invoice_name": {
                    "type": "string",
                    "description": "POS Invoice carrying the charge."
                  },
                  "reason": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "description": "Optional audit reason."
                  },
                  "unique_reference": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "description": "The specific charge row to void (required when several live captures exist)."
                  }
                },
                "required": [
                  "invoice_name"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_integrations.payroc.ledger.payroc_transactions": {
      "post": {
        "tags": [
          "ffl_integrations"
        ],
        "summary": "Every Payroc gateway transaction from `from_date` to `to_date` (inclusive,",
        "description": "store time zone, at most 31 days), matched to the POS. Read-only.\n\n**Auth (derived from code):** Roles: System Manager / Accounts Manager / Accounts User\n\nSource: `apps/ffl_integrations/ffl_integrations/payroc/ledger.py:50`",
        "operationId": "ffl_integrations.payroc.ledger.payroc_transactions",
        "responses": {
          "200": {
            "description": "{from_date, to_date, timezone, truncated, summary, transactions: [row], pos_only: [row]} — a transaction row is {date_time, type, status, batch_status, amount, reference, order_id, card, customer_name, terminal, source (counter | web | virtual terminal | \"\"), pos_doctype, pos_name, pos_amount, pos_refunded, flags: [str]}; pos_only rows are POS captures the search did not return, with the gateway's own status read back (skipped when truncated — the missing days would all land there).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "from_date": {
                    "type": "string",
                    "description": "First day, YYYY-MM-DD."
                  },
                  "to_date": {
                    "type": "string",
                    "description": "Last day, YYYY-MM-DD."
                  }
                },
                "required": [
                  "from_date",
                  "to_date"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_integrations.rsr.promote.backfill_from_rsr": {
      "post": {
        "tags": [
          "ffl_integrations"
        ],
        "summary": "Update RSR-linked Items in place with firearm details that promote_to_item",
        "description": "now writes (manufacturer, model_name, firearm_type, dealer_price, image,\nimage_gallery primary). Skips fields the user has already set non-empty.\n\n**Auth (derived from code):** Roles: Stock Manager / System Manager\n\nSource: `apps/ffl_integrations/ffl_integrations/rsr/promote.py:519`",
        "operationId": "ffl_integrations.rsr.promote.backfill_from_rsr",
        "responses": {
          "200": {
            "description": "{updated, skipped, total}.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "item_codes": {
                    "type": [
                      "array",
                      "null"
                    ],
                    "description": "Optional list or comma-separated string — only those Items are touched. Otherwise scans a local-only candidate net — every Item with `dropship_distributor` set, plus every Item carrying any barcode — and resolves each through `_rsr_for_item` (remote); non-RSR candidates simply come back None and count as skipped."
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_integrations.rsr.promote.lookup_for_item_form": {
      "post": {
        "tags": [
          "ffl_integrations"
        ],
        "summary": "Resolve a UPC / RSR stock # / mfg # to a field map ready for the Item form.",
        "description": "Used by the client script on the Item form (public/js/item_form.js).\nDoes NOT insert anything — the Item form stays in 'unsaved' state and the\nuser can still tweak fields before save.\n\n**Auth (derived from code):** Requires write permission on Item (Frappe DocType permission check).\n\nSource: `apps/ffl_integrations/ffl_integrations/rsr/promote.py:659`",
        "operationId": "ffl_integrations.rsr.promote.lookup_for_item_form",
        "responses": {
          "200": {
            "description": "{found: True, defaults: {item_code, item_name, ...}, rsr: {...}} on hit, or {found: False, scan: ...} on miss.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "scan": {
                    "type": "string",
                    "description": "UPC / RSR stock number / manufacturer part number."
                  }
                },
                "required": [
                  "scan"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_integrations.rsr.promote.migrate_legacy_item_groups": {
      "post": {
        "tags": [
          "ffl_integrations"
        ],
        "summary": "One-shot migrator for the Item Group restructure.",
        "description": "Moves Items out of the legacy flat groups (\"New Firearm\", \"Used Firearm\",\nparent \"Ammunition\") into the type-based leaf groups, and sets `is_used`\nfrom the old group name. Idempotent — safe to re-run.\n\n**Auth (derived from code):** Roles: Stock Manager / System Manager\n\nSource: `apps/ffl_integrations/ffl_integrations/rsr/promote.py:459`",
        "operationId": "ffl_integrations.rsr.promote.migrate_legacy_item_groups",
        "responses": {
          "200": {
            "description": "{firearm_moved, ammo_moved, total}.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        }
      }
    },
    "/api/method/ffl_integrations.rsr.promote.promote_to_item": {
      "post": {
        "tags": [
          "ffl_integrations"
        ],
        "summary": "Build + insert an Item from an RSR Catalog Item.",
        "description": "**Auth (derived from code):** Roles: Stock Manager / System Manager\n\nSource: `apps/ffl_integrations/ffl_integrations/rsr/promote.py:256`",
        "operationId": "ffl_integrations.rsr.promote.promote_to_item",
        "responses": {
          "200": {
            "description": "{item_code, item_name, item_group, has_serial_no, is_firearm, last_rate, stock_uom, found: True} — same shape as ffl_core.api.receive_goods.lookup_item / create_item.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "payload": {
                    "description": "JSON string from JS, or dict from Python: { \"rsr_stock_number\": \"GLK19GEN5\", \"item_code\": \"GLK19GEN5\",     # optional — defaults to rsr.upc, else rsr_stock_number \"item_name\": \"...\",           # optional \"item_group\": \"Barrels\",      # optional override; default: the catalog master's category \"has_serial_no\": 1,           # optional override; default heuristic \"standard_rate\": 649.99,      # optional; defaults to MSRP \"distributor\": \"Sports South\", # optional; a non-RSR house promotes the # SKU through its own provider }"
                  }
                },
                "required": [
                  "payload"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_integrations.rsr.search.search": {
      "post": {
        "tags": [
          "ffl_integrations"
        ],
        "summary": "Search the RSR catalog (legacy-shaped rows for the firearm picker).",
        "description": "Compatibility shim: delegates to the provider's remote search and maps\nrows back to the legacy key shape ffl_core.bundle.js consumes.\nDegrades to [] when the API is unreachable.\n\n**Auth (derived from code):** Roles: Sales User / Sales Manager / Stock Manager / System Manager\n\nSource: `apps/ffl_integrations/ffl_integrations/rsr/search.py:15`",
        "operationId": "ffl_integrations.rsr.search.search",
        "responses": {
          "200": {
            "description": "[{rsr_stock_number, upc, mfg_number, manufacturer, model, short_description, department_number, msrp, dealer_price, map_price, quantity, ffl_required, status_flag, image_url, image_url_hires}].",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "array"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "query": {
                    "type": "string",
                    "description": "Search term (blank returns [])."
                  },
                  "limit": {
                    "type": "integer",
                    "description": "Row cap, clamped to 1–50 (default 10).",
                    "default": 10
                  }
                },
                "required": [
                  "query"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_integrations.shipstation.api.push_shipment": {
      "post": {
        "tags": [
          "ffl_integrations"
        ],
        "summary": "Push a submitted order to ShipStation (the Pending Order Ship action).",
        "description": "Staff buy the label in ShipStation. Synchronous; idempotent (a second\ncall after success is a no-op); persists nothing on API failure, so a\nretry after fixing the cause is safe. Independent of the Dispose step.\n\n**Auth (derived from code):** Roles: Sales User / Sales Manager / Stock Manager / System Manager\n\n**Permissions:** Counter shipping roles.\n\nSource: `apps/ffl_integrations/ffl_integrations/shipstation/api.py:273`",
        "operationId": "ffl_integrations.shipstation.api.push_shipment",
        "responses": {
          "200": {
            "description": "{ok, shipstation_order_id, shipstation_status, ...} — or {ok: True, already: True, ...} when previously pushed.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "sales_invoice": {
                    "type": "string",
                    "description": "Submitted Sales Invoice with a resolvable ship-to."
                  }
                },
                "required": [
                  "sales_invoice"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_integrations.shipstation.api.test_connection": {
      "post": {
        "tags": [
          "ffl_integrations"
        ],
        "summary": "Probe the ShipStation connection via GET /v2/carriers.",
        "description": "The Settings form's Test Connection button.\n\n**Auth (derived from code):** Roles: System Manager\n\n**Permissions:** System Manager (fires live outbound calls and returns the account's warehouse list).\n\nSource: `apps/ffl_integrations/ffl_integrations/shipstation/api.py:429`",
        "operationId": "ffl_integrations.shipstation.api.test_connection",
        "responses": {
          "200": {
            "description": "{ok, carrier_count, sandbox, warehouses: [...]}.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        }
      }
    },
    "/api/method/ffl_woo_sync.woocommerce.antique.retire_antique_web_order_now": {
      "post": {
        "tags": [
          "ffl_woo_sync"
        ],
        "summary": "Manually retry retiring an antique web order (no bound-book entry).",
        "description": "For an antique web order whose retirement failed (Error Log).\n\n**Auth (derived from code):** Roles: Sales User / Sales Manager / Stock Manager / System Manager\n\n**Permissions:** Counter roles (same as the other fulfillment actions).\n\nSource: `apps/ffl_woo_sync/ffl_woo_sync/woocommerce/antique.py:149`",
        "operationId": "ffl_woo_sync.woocommerce.antique.retire_antique_web_order_now",
        "responses": {
          "200": {
            "description": "The retirement result from retire_antique_web_order.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "woo_online_order": {
                    "type": "string",
                    "description": "Woo Online Order name (antique lines only)."
                  }
                },
                "required": [
                  "woo_online_order"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_woo_sync.woocommerce.categories.recategorize_store": {
      "post": {
        "tags": [
          "ffl_woo_sync"
        ],
        "summary": "Put the products on the store(s) in their tree category: the products whose",
        "description": "tree categories are not their node's term — e.g. filed under a parent before\ntheir category was created on the store, or every product on a store's first\nApply (linking a term moves nothing by itself). Categories outside the tree\n(Clearance, Open Box …) are kept. Per-serial guns count as products and are\ncounted apart (``by_doctype``).\n\nLimit: a product's full push (and the catalog feed's re-categorise) still\nwrites its tree category alone, dropping Clearance / Open Box — only this\ncatch-up keeps them.\n\n**Auth (derived from code):** Roles: System Manager\n\n**Permissions:** System Manager.\n\nSource: `apps/ffl_woo_sync/ffl_woo_sync/woocommerce/categories.py:673`",
        "operationId": "ffl_woo_sync.woocommerce.categories.recategorize_store",
        "responses": {
          "200": {
            "description": "{site: {checked, to_move, by_doctype: {Item, Serial No}, moves: [{doctype, now, want, count, sample: [product ids]}] (grouped by the tree categories now → the one to get, largest first), no_term, no_node, gone, sample: [{doctype, name, item, product_id, category, now, want, set}] (the first 50)}}; applying adds queued: true per store. A store that does not follow the tree (or is not connected): {skipped: \"off\" | \"not connected\"}.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "site": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "description": "\"retail\" (the only store); empty = every store that follows the tree."
                  },
                  "dry_run": {
                    "type": "integer",
                    "description": "1 (default) reports only; 0 moves them in a background job (category only, paced; a product the store refuses lands in the Error Log).",
                    "default": 1
                  },
                  "under": {
                    "description": "node slugs (a list, JSON list or comma-separated) — only the products filed in their subtrees; empty = the whole store."
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_woo_sync.woocommerce.client_api.delist_item_now": {
      "post": {
        "tags": [
          "ffl_woo_sync"
        ],
        "summary": "Set the WooCommerce product for an Item to ``draft`` + stock 0.",
        "description": "The operator's deliberate delist — the only delist_item caller that\nraises the republish sentinel.\n\n**Auth (derived from code):** Roles: Stock Manager / System Manager\n\nSource: `apps/ffl_woo_sync/ffl_woo_sync/woocommerce/client_api.py:296`",
        "operationId": "ffl_woo_sync.woocommerce.client_api.delist_item_now",
        "responses": {
          "200": {
            "description": "{\"ok\": True, \"raw\": <WC response>}.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "item_code": {
                    "type": "string",
                    "description": "The Item to delist."
                  },
                  "site": {
                    "type": "string",
                    "description": "\"retail\" (default; the only store).",
                    "default": "retail"
                  }
                },
                "required": [
                  "item_code"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_woo_sync.woocommerce.client_api.delist_serial_now": {
      "post": {
        "tags": [
          "ffl_woo_sync"
        ],
        "summary": "Set the WooCommerce product for a Serial No to ``draft`` + stock 0.",
        "description": "**Auth (derived from code):** Roles: Stock Manager / System Manager\n\nSource: `apps/ffl_woo_sync/ffl_woo_sync/woocommerce/client_api.py:363`",
        "operationId": "ffl_woo_sync.woocommerce.client_api.delist_serial_now",
        "responses": {
          "200": {
            "description": "{\"ok\": True, \"raw\": <WC response>}.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "serial_no": {
                    "type": "string",
                    "description": "The Serial No to delist."
                  },
                  "site": {
                    "type": "string",
                    "description": "\"retail\" (default; the only store).",
                    "default": "retail"
                  }
                },
                "required": [
                  "serial_no"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_woo_sync.woocommerce.client_api.pull_product_from_woo": {
      "post": {
        "tags": [
          "ffl_woo_sync"
        ],
        "summary": "Overwrite a POS record's listing content from its WooCommerce product.",
        "description": "The reverse of push_item_now / push_serial_now, for the storefront plugin's product\npage's \"overwrite POS from WooCommerce\" button: pulls title, description,\nprice and gallery images from the live WC product and writes them onto\nthe Item (or, for an ``item_code::serial_no`` SKU, the Serial No).\nStock and attributes are never pulled — the POS stays their source of\ntruth. The save runs under the inbound loop guard, so doc_events does not\npush the change straight back at WooCommerce.\n\n**Auth (derived from code):** Roles: Stock Manager / System Manager\n\nSource: `apps/ffl_woo_sync/ffl_woo_sync/woocommerce/client_api.py:470`",
        "operationId": "ffl_woo_sync.woocommerce.client_api.pull_product_from_woo",
        "responses": {
          "200": {
            "description": "{\"ok\": True, \"doctype\": ..., \"name\": ..., \"updated\": {field: summary}, \"images_imported\": n, \"image_errors\": [...]} — plus \"price_note\" (optional) when the price was deliberately not written (uniform-priced parent). The Item branch reports the applied price as updated[\"selling_price\"] (it lands via the canonical selling-price helper, not a bare standard_rate write). Refusals (unknown record, never pushed, missing write permission, product deleted on the store) raise a ValidationError with the reason.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "sku": {
                    "type": "string",
                    "description": "WooCommerce product SKU — ``item_code`` for an item-level product, ``item_code::serial_no`` for a per-serial firearm."
                  },
                  "site": {
                    "type": "string",
                    "description": "\"retail\" (default; the only store).",
                    "default": "retail"
                  }
                },
                "required": [
                  "sku"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_woo_sync.woocommerce.client_api.push_all_serials": {
      "post": {
        "tags": [
          "ffl_woo_sync"
        ],
        "summary": "Push (create or update) WC products for all Active Serial Nos of an Item.",
        "description": "Uses a single pre-built client and pre-fetched attribute IDs to minimise\nHTTP round-trips.  Returns per-serial results and any errors encountered.\n\n.. note:: **Aggregating semantics** — every serial is attempted regardless\n   of earlier failures; errors are collected and returned rather than\n   re-raised.  This differs from\n   :func:`ffl_woo_sync.woocommerce.sync.push_all_serials` which is\n   fail-fast (re-raises the first per-serial exception immediately).\n\n**Auth (derived from code):** Roles: Stock Manager / System Manager\n\nSource: `apps/ffl_woo_sync/ffl_woo_sync/woocommerce/client_api.py:249`",
        "operationId": "ffl_woo_sync.woocommerce.client_api.push_all_serials",
        "responses": {
          "200": {
            "description": "{ok, pushed, errors, skipped, total}.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "item_code": {
                    "type": "string",
                    "description": "The Item whose Active serials to push."
                  },
                  "site": {
                    "type": "string",
                    "description": "\"retail\" (default; the only store).",
                    "default": "retail"
                  }
                },
                "required": [
                  "item_code"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_woo_sync.woocommerce.client_api.push_item_now": {
      "post": {
        "tags": [
          "ffl_woo_sync"
        ],
        "summary": "Push (create or update) the WooCommerce product(s) for an Item.",
        "description": "Routing is determined server-side so all callers (Item form button, MCP,\nfuture automation) behave correctly without any client-side detection:\n\n- **Per-serial firearm** (``is_firearm=1``, ``uniform_sell_price=0``):\n  pushes every Active Serial No via :func:`ffl_woo_sync.woocommerce.sync.push_serial`.\n  Returns ``{\"ok\": bool, \"pushed\": [...], \"errors\": [...], \"skipped\": [...],\n  \"total\": int}``.  This branch does **not** pass ``_relist``: a hidden gun\n  stays hidden and lands in ``skipped`` (an Item-level bulk\n  relist would also revive guns hidden one-by-one for holds or repairs).\n  The per-gun route is the Serial No form's own button.\n- **Non-firearm / uniform-price firearm**:\n  single item-level push via :func:`ffl_woo_sync.woocommerce.sync.push_item`.\n  Returns ``{\"ok\": True, \"woo_product_id\": \"<id>\", \"raw\": <WC response>}``.\n  A template Item pushes its variable product and every variant; ``ok`` is\n  False when a variation failed (``variation_errors``), and variants whose\n  variation was deleted on the store are listed in ``dangling_variations``.\n\n**Auth (derived from code):** Roles: Stock Manager / System Manager\n\nSource: `apps/ffl_woo_sync/ffl_woo_sync/woocommerce/client_api.py:179`",
        "operationId": "ffl_woo_sync.woocommerce.client_api.push_item_now",
        "responses": {
          "200": {
            "description": "Per-serial branch: {ok, pushed, errors, skipped, total}; item-level branch: {ok, woo_product_id, raw, variation_errors, dangling_variations}.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "item_code": {
                    "type": "string",
                    "description": "The Item to push."
                  },
                  "site": {
                    "type": "string",
                    "description": "\"retail\" (default; the only store).",
                    "default": "retail"
                  }
                },
                "required": [
                  "item_code"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_woo_sync.woocommerce.client_api.push_serial_now": {
      "post": {
        "tags": [
          "ffl_woo_sync"
        ],
        "summary": "Push (create or update) the WooCommerce product for a single Serial No.",
        "description": "An operator's explicit push is the clearest relist there is, so this\noverrides the hidden-serial guard (a human may always undo a human's\nhide).\n\n**Auth (derived from code):** Roles: Stock Manager / System Manager\n\nSource: `apps/ffl_woo_sync/ffl_woo_sync/woocommerce/client_api.py:325`",
        "operationId": "ffl_woo_sync.woocommerce.client_api.push_serial_now",
        "responses": {
          "200": {
            "description": "{\"ok\": True, \"woo_product_id\": \"<id>\", \"raw\": <WC response>} — or a skipped response when the sync guard refuses.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "serial_no": {
                    "type": "string",
                    "description": "The Serial No to push."
                  },
                  "site": {
                    "type": "string",
                    "description": "\"retail\" (default; the only store).",
                    "default": "retail"
                  }
                },
                "required": [
                  "serial_no"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_woo_sync.woocommerce.client_api.reconcile_now": {
      "post": {
        "tags": [
          "ffl_woo_sync"
        ],
        "summary": "Push the item product + all Active serials in a single call.",
        "description": "Uses a shared client and pre-fetched attribute IDs.  Returns combined\nresults: the item push result plus per-serial results and any errors.\n\nSuitable for \"initial listing\" of a per-serial firearm item where you want\nto bring everything live in one operation.\n\nFULL-PAYLOAD by design: as a deliberate,\nconfirmed bulk action it keeps the manual-push semantics — which means it\nWILL overwrite wp-admin content edits (title / description / images) with\nthe POS versions on every product it touches. Routine drift healing belongs\nto the scheduled reconcile, which is pos_fields_only and content-safe.\n\n**Auth (derived from code):** Roles: Stock Manager / System Manager\n\nSource: `apps/ffl_woo_sync/ffl_woo_sync/woocommerce/client_api.py:388`",
        "operationId": "ffl_woo_sync.woocommerce.client_api.reconcile_now",
        "responses": {
          "200": {
            "description": "{ok, item_result, item_error, dangling, pushed_serials, serial_errors, skipped_serials, variation_errors, dangling_variations}.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "item_code": {
                    "type": "string",
                    "description": "The Item to reconcile."
                  },
                  "site": {
                    "type": "string",
                    "description": "\"retail\" (default; the only store).",
                    "default": "retail"
                  }
                },
                "required": [
                  "item_code"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_woo_sync.woocommerce.client_api.test_connection": {
      "post": {
        "tags": [
          "ffl_woo_sync"
        ],
        "summary": "Probe the WooCommerce store via GET /products?per_page=1 (read auth only).",
        "description": "**Auth (derived from code):** Roles: System Manager\n\nSource: `apps/ffl_woo_sync/ffl_woo_sync/woocommerce/client_api.py:148`",
        "operationId": "ffl_woo_sync.woocommerce.client_api.test_connection",
        "responses": {
          "200": {
            "description": "{\"ok\": True, \"store_url\": ..., \"raw\": <probe info>}.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "site": {
                    "type": "string",
                    "description": "\"retail\" (default; the only store).",
                    "default": "retail"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_woo_sync.woocommerce.client_api.web_events": {
      "post": {
        "tags": [
          "ffl_woo_sync"
        ],
        "summary": "Take the website's visitor events: a newsletter signup, a back-in-stock or model alert request.",
        "description": "Each event is processed on its own; one that fails leaves nothing behind and does not stop the\nrest. A repeated event id is answered as accepted again and processed only once. Nothing is\nemailed. The whole call is refused while Marketing Settings › Enabled is off, and the website\nsends the events again later.\n\n**Auth (derived from code):** Roles: Stock Manager / System Manager\n\nSource: `apps/ffl_woo_sync/ffl_woo_sync/woocommerce/client_api.py:547`",
        "operationId": "ffl_woo_sync.woocommerce.client_api.web_events",
        "responses": {
          "200": {
            "description": "{\"accepted\": [id, ...], \"rejected\": [{\"id\": ..., \"reason\": ...}, ...]}. ``reason`` is ``unknown_type``, ``invalid_email`` or ``invalid_data``; an event in neither list failed unexpectedly (an Error Log is written) and should be sent again.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "events": {
                    "description": "A list (or its JSON) of at most 100 events, each ``{\"id\", \"type\", \"occurred_at\", \"data\"}``. Types: ``contact.subscribed`` (data: email, first_name, last_name, source, page_url, ip, tags, interests, coupon) and ``alert.requested`` (data: email, kind ``back_in_stock`` or ``model``, sku, product_id, product_name, url, model_key, model_label)."
                  }
                },
                "required": [
                  "events"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_woo_sync.woocommerce.client_api.web_inquiry": {
      "post": {
        "tags": [
          "ffl_woo_sync"
        ],
        "summary": "File a website form submission in CRM: a price request, a sell-your-gun form or a question.",
        "description": "The email decides where it goes, as for incoming mail: a customer's open deal (one is opened when\nthey have none), else their existing lead, else a new lead. The text goes on it as a note and as a\nreceived mail from the customer (staff answer it with Reply), and the gun asked about as a product line. A sell-your-gun request always makes a deal of its own, its\nknown fields on the deal and its photos (links on the store's website) copied in later. Nothing is\nemailed to the customer. A repeat of the same ``event_id`` files nothing more. Does nothing when\nCRM is not installed.\n\n**Auth (derived from code):** Roles: Stock Manager / System Manager\n\nSource: `apps/ffl_woo_sync/ffl_woo_sync/woocommerce/client_api.py:510`",
        "operationId": "ffl_woo_sync.woocommerce.client_api.web_inquiry",
        "responses": {
          "200": {
            "description": "{\"filed\": True, \"doctype\": \"CRM Lead\" | \"CRM Deal\", \"name\": ..., \"created\": bool}, or {\"filed\": False, \"reason\": ...} when CRM is not installed. Fields are length-capped and stored escaped.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "kind": {
                    "type": "string",
                    "description": "``map_price``, ``sell_gun`` or ``ask``; anything else is refused."
                  },
                  "event_id": {
                    "type": "string",
                    "description": "The website's id for this submission; makes a retry harmless."
                  },
                  "email": {
                    "type": "string",
                    "description": "The sender's email address (required, validated)."
                  },
                  "full_name": {
                    "type": "string",
                    "description": "The sender's name.",
                    "default": ""
                  },
                  "phone": {
                    "type": "string",
                    "description": "The sender's phone number.",
                    "default": ""
                  },
                  "message": {
                    "type": "string",
                    "description": "What they wrote.",
                    "default": ""
                  },
                  "sku": {
                    "type": "string",
                    "description": "The gun asked about, ``item_code`` or ``item_code::serial_no``; unknown ones are only noted.",
                    "default": ""
                  },
                  "url": {
                    "type": "string",
                    "description": "The product page, shown as a link in the note.",
                    "default": ""
                  },
                  "details": {
                    "description": "A flat object of label -> value (the sell-your-gun form's fields), as JSON or a dict."
                  },
                  "photos": {
                    "description": "A list of https photo URLs, as JSON or a list."
                  }
                },
                "required": [
                  "kind",
                  "event_id",
                  "email"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_woo_sync.woocommerce.condition_backfill.backfill_condition_attributes": {
      "post": {
        "tags": [
          "ffl_woo_sync"
        ],
        "summary": "Re-push ONLY the attributes to existing retail Woo firearm products.",
        "description": "The attributes are Caliber / Condition / Manufacturer / Model.\n\nFixes stale ``pa_condition`` terms after a grade / ``is_used`` correction in\nPOS: lean machine pushes never carry attributes, so they never get there on\ntheir own. The payload is exactly ``{\"attributes\": [...]}`` per product —\nname, description, images, price, stock and meta are never sent, and no\nPOS record is written. Products on the shop that were hidden\n(``woo_delisted``) or never listed are skipped.\n\nAttributes are authoritative on a PUT: any attribute on the product other\nthan those four is removed. Run with ``dry_run=1`` first. A big run is\nbest done with ``bench execute`` rather than over HTTP (it is synchronous).\n\n**Auth (derived from code):** Roles: System Manager\n\nSource: `apps/ffl_woo_sync/ffl_woo_sync/woocommerce/condition_backfill.py:153`",
        "operationId": "ffl_woo_sync.woocommerce.condition_backfill.backfill_condition_attributes",
        "responses": {
          "200": {
            "description": "``{\"pushed\": n, \"skipped\": n, \"errors\": n, \"dry_run\": bool, \"would_push\": n, \"skipped_by_reason\": {...}, \"error_details\": [...]}`` — ``pushed`` is products the store accepted; with ``dry_run`` it is 0 and ``would_push`` counts the products that would be sent."
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "serials": {
                    "description": "Serial No names (list, JSON list or comma-separated). Per-serial firearms only; a serial of a uniform-price Item is skipped (name the Item instead)."
                  },
                  "item_codes": {
                    "description": "Item codes. A uniform-price firearm Item pushes its own product; a per-serial firearm Item expands to its live serials."
                  },
                  "dry_run": {
                    "description": "1 builds every payload and reports what WOULD be sent, without sending (still reads the store's attribute ids).",
                    "default": 0
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_woo_sync.woocommerce.connect.start_connect": {
      "post": {
        "tags": [
          "ffl_woo_sync"
        ],
        "summary": "Begin a one-click connection: issue a one-time state and return the store's approval URL.",
        "description": "The saved Store URL is used; the browser is sent to WooCommerce's\n``/wc-auth/v1/authorize`` page, which posts a new read/write REST key back to\n``wc_auth_callback`` once the store owner approves.\n\n**Auth (derived from code):** Roles: System Manager\n\nSource: `apps/ffl_woo_sync/ffl_woo_sync/woocommerce/connect.py:169`",
        "operationId": "ffl_woo_sync.woocommerce.connect.start_connect",
        "responses": {
          "200": {
            "description": "{\"url\": <the store's wc-auth approval URL>}.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        }
      }
    },
    "/api/method/ffl_woo_sync.woocommerce.connect.wc_auth_callback": {
      "post": {
        "tags": [
          "webhooks"
        ],
        "summary": "WooCommerce wc-auth callback: receives the REST key the store owner approved.",
        "description": "**Auth (derived from code):** Guest — no session; the endpoint verifies the caller itself (HMAC signature, HTTP Basic credentials or a one-time token).\n\n**Payload:** WooCommerce's JSON body ``{key_id, user_id, consumer_key, consumer_secret, key_permissions}``. ``user_id`` carries the one-time state from ``start_connect``.\n\nSource: `apps/ffl_woo_sync/ffl_woo_sync/woocommerce/connect.py:227`",
        "operationId": "ffl_woo_sync.woocommerce.connect.wc_auth_callback",
        "responses": {
          "200": {
            "description": "200 ``{\"ok\": true}`` once the key is stored and the rest of the connection is queued; 400 ``{\"ok\": false, \"error\"}`` for an unknown, expired or used state, a key that is not read/write, or a store that is no longer the one in Settings.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "security": [],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "user_id": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "description": "The one-time state; valid for 15 minutes and spent on first use."
                  },
                  "consumer_key": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "description": "The new WooCommerce consumer key."
                  },
                  "consumer_secret": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "description": "The new WooCommerce consumer secret."
                  },
                  "key_permissions": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "description": "Must be ``read_write``."
                  },
                  "key_id": {
                    "description": "WooCommerce's id for the key (not used)."
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_woo_sync.woocommerce.customer_import.import_customers": {
      "post": {
        "tags": [
          "ffl_woo_sync"
        ],
        "summary": "Make a Customer for every online buyer and registered store account the POS does not have.",
        "description": "**Auth (derived from code):** Roles: System Manager\n\nSource: `apps/ffl_woo_sync/ffl_woo_sync/woocommerce/customer_import.py:121`",
        "operationId": "ffl_woo_sync.woocommerce.customer_import.import_customers",
        "responses": {
          "200": {
            "description": "dict: {\"dry_run\", \"emails\" (distinct addresses found), \"existing\" (already a Customer), \"invalid\" (not an email address), \"created\" (or would be), \"phone_dropped\" (created without the store's phone, which the POS rejected), \"errors\": [{email, error}], \"sample\": [{email, name}] of the first new ones}.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "dry_run": {
                    "description": "Anything but an explicit 0 / false / no (the default is 1) reads the store and reports what would be created, creating nothing.",
                    "default": 1
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_woo_sync.woocommerce.dangling.woo_audit_dangling_ids": {
      "post": {
        "tags": [
          "ffl_woo_sync"
        ],
        "summary": "Audit stored Woo product ids for ones whose WC product was deleted (404).",
        "description": "Scans every connected store by default, and a store it cannot build a client\nfor is reported as skipped rather than aborting the run: letting the config\nerror out of here would 500 the request AND roll back any repairs already\nmade in the same transaction.\n\n**Auth (derived from code):** Roles: System Manager\n\nSource: `apps/ffl_woo_sync/ffl_woo_sync/woocommerce/dangling.py:137`",
        "operationId": "ffl_woo_sync.woocommerce.dangling.woo_audit_dangling_ids",
        "responses": {
          "200": {
            "description": "{ \"checked\": <int>,                 # ids verified against WooCommerce \"dangling\": [{\"doctype\",\"name\",\"field\",\"site\",\"woo_id\"}, ...], \"fixed\": <int>,                   # ids nulled (0 unless fix) \"skipped\": [{\"site\",\"reason\"}, ...],   # stores with no usable client \"counts\": {\"by_doctype\": {...}, \"by_site\": {...}}, }"
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "fix": {
                    "description": "Report-only by default; 1 (or True) nulls each dangling id and leaves a Comment + warning log.",
                    "default": 0
                  },
                  "batch_size": {
                    "description": "Clamped to 1..200; bounds each verification chunk — a fat-finger clamp on the parameter, not a rate limit; every candidate is checked.",
                    "default": 50
                  },
                  "site": {
                    "description": "Limits to one store — \"retail\", the only one (default: all). Any other value raises a ValidationError."
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_woo_sync.woocommerce.fulfillment.dispose_web_order": {
      "post": {
        "tags": [
          "ffl_woo_sync"
        ],
        "summary": "Dispose the firearms on a paid Woo Online Order (web Dispose action).",
        "description": "No ShipStation push here: the store's own ShipStation WooCommerce\nplugin creates the shipment. Books one submitted \"FFL Transfer\"\ndisposition per not-yet-disposed firearm serial; each disposition's own\non_submit issues the stock-out and enqueues the FastBound push. No\nSales Invoice is created. Idempotent via the {serial, woo_online_order}\nguard.\n\nRefuses an in-store pickup — an order whose receiving FFL is this store's own\nlicence (``FFL Settings.own_ffl_license``). There is no far-end dealer to\ntransfer to; the buyer collects at the counter under a retail 4473, and\nbooking it here would write a disposition to ourselves into the bound book.\n\n**Auth (derived from code):** Roles: Sales User / Sales Manager / Stock Manager / System Manager\n\n**Permissions:** Counter roles.\n\nSource: `apps/ffl_woo_sync/ffl_woo_sync/woocommerce/fulfillment.py:636`",
        "operationId": "ffl_woo_sync.woocommerce.fulfillment.dispose_web_order",
        "responses": {
          "200": {
            "description": "{ok, dispositions: [names], disposed_count, sales_invoice, invoice_status, ...}.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "woo_online_order": {
                    "type": "string",
                    "description": "Woo Online Order name (must be Pending Fulfillment)."
                  },
                  "cr_details": {
                    "description": "Staff verification captured in the dispose dialog for a Type 03 (Curio & Relic) order — see cr_transfer.py. Defaults to None and is only consulted for a C&R order. Dict from Python or JSON string from the browser."
                  },
                  "locations": {
                    "description": "Optional {woo_line_id: Storage Location} — where in the store staff took each loose-stock line from (see get_dispose_stock_lines). The units leave that location with the order's delivery; a line left out goes to the \"to confirm\" list on the Storage Locations page."
                  }
                },
                "required": [
                  "woo_online_order"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_woo_sync.woocommerce.fulfillment.get_dispose_stock_lines": {
      "post": {
        "tags": [
          "ffl_woo_sync"
        ],
        "summary": "The loose-stock lines of a web order and where in the store each can be taken",
        "description": "from, for the \"where did these come from?\" step of Dispose.\n\n**Auth (derived from code):** Roles: Sales User / Sales Manager / Stock Manager / System Manager\n\nSource: `apps/ffl_woo_sync/ffl_woo_sync/woocommerce/fulfillment.py:589`",
        "operationId": "ffl_woo_sync.woocommerce.fulfillment.get_dispose_stock_lines",
        "responses": {
          "200": {
            "description": "[{line, item_code, item_name, qty, locations: [{location, label, qty}], unassigned, chosen}] -- one per line that ships from the shelf as loose stock. ``chosen`` is the location already recorded for the line, or the sole place the item can only have come from (exactly one holds it, none is unassigned).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "array"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "woo_online_order": {
                    "type": "string",
                    "description": "Woo Online Order name."
                  }
                },
                "required": [
                  "woo_online_order"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_woo_sync.woocommerce.fulfillment.list_pending_web_orders": {
      "post": {
        "tags": [
          "ffl_woo_sync"
        ],
        "summary": "Rows for the Pending Order page: paid Woo Online Orders still awaiting",
        "description": "fulfillment. Shaped to match ffl_core.api.manual_order.list_pending_dispositions\nso the page renders both sources uniformly (these carry source=\"woo\").\n\nAn order POS cannot act on is omitted — no firearm serial row, no procure-to-store\nleg, nothing left to order from a distributor, and positive proof that no line is a regulated\nfirearm (see the guard in the loop). An order that merely LOOKS actionless because\nwe failed to recognise its firearm line stays listed and is logged.\n\n**Auth (derived from code):** Roles: Sales User / Sales Manager / Stock Manager / System Manager\n\n**Permissions:** Counter roles.\n\nSource: `apps/ffl_woo_sync/ffl_woo_sync/woocommerce/fulfillment.py:304`",
        "operationId": "ffl_woo_sync.woocommerce.fulfillment.list_pending_web_orders",
        "responses": {
          "200": {
            "description": "Pending-order cards (source=\"woo\"), shaped like list_pending_dispositions rows.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "array"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        }
      }
    },
    "/api/method/ffl_woo_sync.woocommerce.fulfillment.reserved_web_serials": {
      "post": {
        "tags": [
          "ffl_woo_sync"
        ],
        "summary": "Web-order hold registry for one Item's in-stock serials.",
        "description": "Serials held by a Woo Online Order still in 'Pending Fulfillment':\nconfirmed_serial (kind=\"woo_assigned\") and stock_hold_serial\n(kind=\"woo_held\"). Drives the 'Pending' pill on the Item form Serial\nNumbers tab.\n\n**Auth (derived from code):** Role-filtered: callers without Roles Sales User / Sales Manager / Stock Manager / System Manager receive an EMPTY result instead of an error.\n\n**Permissions:** Canonical shipping roles (passive read, same gate as reserved_counter_serials). A caller WITHOUT the role gets an empty {} back silently — no error is raised — so an empty result is not proof of \"no holds\".\n\nSource: `apps/ffl_woo_sync/ffl_woo_sync/woocommerce/fulfillment.py:1022`",
        "operationId": "ffl_woo_sync.woocommerce.fulfillment.reserved_web_serials",
        "responses": {
          "200": {
            "description": "{serial: {source, ref, kind, tooltip, url}} — only held serials appear.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "item_code": {
                    "type": "string",
                    "description": "Item whose in-stock serials to check."
                  }
                },
                "required": [
                  "item_code"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_woo_sync.woocommerce.order_audit.run_web_revenue_backstop_now": {
      "post": {
        "tags": [
          "ffl_woo_sync"
        ],
        "summary": "Run the web revenue / stock backstop sweep by hand.",
        "description": "Same sweep the 2-hourly cron runs (``scheduled_web_revenue_backstop``):\nbooks the revenue of Transferred web orders that never got an invoice and\nissues the missing accessory stock legs, alerting instead of acting on\nanything a person already touched.\n\n**Auth (derived from code):** Roles: Sales User / Sales Manager / Stock Manager / System Manager\n\n**Permissions:** Counter roles (same as the other web-order accounting actions).\n\nSource: `apps/ffl_woo_sync/ffl_woo_sync/woocommerce/order_audit.py:456`",
        "operationId": "ffl_woo_sync.woocommerce.order_audit.run_web_revenue_backstop_now",
        "responses": {
          "200": {
            "description": "``{\"booked\": [...], \"delivered\": [...], \"failed\": [...], \"held\": [...]}`` — order / invoice names per outcome.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        }
      }
    },
    "/api/method/ffl_woo_sync.woocommerce.order_audit.shipped_undisposed_orders": {
      "post": {
        "tags": [
          "ffl_woo_sync"
        ],
        "summary": "List web orders WooCommerce says shipped while POS still has them open.",
        "description": "Read-only: the same query (and grace period) as the daily\n``tasks.alert_shipped_undisposed_orders`` alarm, without its Error Log, so\nthe list and the alarm cannot disagree. Each one is a firearm that may have\nleft with no disposition booked: confirm the serial against ShipStation and\nFastBound, then dispose the order in POS.\n\n**Auth (derived from code):** Roles: Sales User / Sales Manager / Stock Manager / System Manager\n\nSource: `apps/ffl_woo_sync/ffl_woo_sync/woocommerce/order_audit.py:432`",
        "operationId": "ffl_woo_sync.woocommerce.order_audit.shipped_undisposed_orders",
        "responses": {
          "200": {
            "description": "``[{\"name\", \"woo_order_id\", \"customer_name\", \"modified\"}, ...]``, oldest first; empty when nothing is outstanding.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "array"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        }
      }
    },
    "/api/method/ffl_woo_sync.woocommerce.order_audit.web_stock_legs_outstanding": {
      "post": {
        "tags": [
          "ffl_woo_sync"
        ],
        "summary": "List web invoices whose accessory stock never left — the month-end control.",
        "description": "Read-only. Before closing a month, call this for that month (first to last\nday) and expect an empty list: a web invoice whose accessory Delivery Note\nnever posted still shows a cost in the Sales Report (its cost column is\nqty x Bin valuation rate, not the GL), so the report cannot reveal the gap\nand its cost can only be trusted against GL COGS once this is empty. A\nnon-zero count lists the invoices: run ``run_web_revenue_backstop_now`` to\nissue the ones that can be issued, handle the rest by hand. Also before\nclosing: no open ToDo on a Sales Invoice or Woo Online Order from this\nmachinery (a stock leg that could not be issued, a revenue booking that\nkeeps failing, an order whose only invoice is cancelled, a refund held\nbecause a person is holding the stock leg, an invoice left in Draft on a\ntotal mismatch) — each is an unbooked sale or an overstated shelf. A\nbackfilled Delivery Note is posted on the invoice's own date while the\nperiod is open (no Period Closing Voucher, no accounts/stock freeze, month\nnot yet handed to an outside accountant), otherwise on the correction date\nwith a comment saying so. After a submitted sales return against a web\nDelivery Note, expect report cost to exceed GL COGS by the returned amount.\n\n**Auth (derived from code):** Roles: Sales User / Sales Manager / Stock Manager / System Manager\n\n**Permissions:** Counter roles (same as the other web-order accounting actions).\n\nSource: `apps/ffl_woo_sync/ffl_woo_sync/woocommerce/order_audit.py:391`",
        "operationId": "ffl_woo_sync.woocommerce.order_audit.web_stock_legs_outstanding",
        "responses": {
          "200": {
            "description": "``{\"invoices\": [...], \"count\": n}`` — submitted web Sales Invoices still owing a Delivery Note in the window.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "from_date": {
                    "description": "First posting date to consider (default: 30 days ago)."
                  },
                  "to_date": {
                    "description": "Last posting date to consider (default: no upper bound)."
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_woo_sync.woocommerce.pickup.pickup_web_order": {
      "post": {
        "tags": [
          "ffl_woo_sync"
        ],
        "summary": "Hand an in-store-pickup web order to the counter.",
        "description": "Opens a DRAFT POS Invoice for a firearm order — already paid, serials carried\nfrom WooCommerce where staff typed them — so the cashier can run the 4473 and\nComplete Order the ordinary way. An order with no regulated firearm needs no\n4473 and is finished on the spot instead.\n\nThe web order deliberately STAYS in the Pending Order queue until that counter\ninvoice is submitted (see :func:`close_web_order_on_pos_submit`). Retiring it\nat the click would hide the one case that needs watching: a draft opened and\nabandoned, with the gun still in stock, the money still unbooked, and the\ncustomer possibly already holding the rifle.\n\n**Auth (derived from code):** Roles: Sales User / Sales Manager / Stock Manager / System Manager\n\n**Permissions:** Counter roles.\n\nSource: `apps/ffl_woo_sync/ffl_woo_sync/woocommerce/pickup.py:360`",
        "operationId": "ffl_woo_sync.woocommerce.pickup.pickup_web_order",
        "responses": {
          "200": {
            "description": "{ok, mode: \"counter\"|\"closed\", pos_invoice, order_status}.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "woo_online_order": {
                    "type": "string",
                    "description": "Woo Online Order name (must be Pending Fulfillment and addressed to this store's own FFL)."
                  }
                },
                "required": [
                  "woo_online_order"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_woo_sync.woocommerce.refunds.reconcile_web_order_refund": {
      "post": {
        "tags": [
          "ffl_woo_sync"
        ],
        "summary": "Reconcile a web order's Sales Invoice to its Woo refunds.",
        "description": "Manual/enqueued entry point.\n\n**Auth (derived from code):** Roles: Sales User / Sales Manager / Stock Manager / System Manager\n\n**Permissions:** Counter roles (same as the other web-order accounting actions).\n\nSource: `apps/ffl_woo_sync/ffl_woo_sync/woocommerce/refunds.py:622`",
        "operationId": "ffl_woo_sync.woocommerce.refunds.reconcile_web_order_refund",
        "responses": {
          "200": {
            "description": "The reconcile result (credit notes booked / already in sync).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "woo_online_order": {
                    "type": "string",
                    "description": "Woo Online Order name."
                  }
                },
                "required": [
                  "woo_online_order"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_woo_sync.woocommerce.revenue.create_web_invoice_now": {
      "post": {
        "tags": [
          "ffl_woo_sync"
        ],
        "summary": "Manually retry the revenue Sales Invoice for a Transferred web order.",
        "description": "For a web order whose revenue booking failed (error log / draft\nmismatch).\n\n**Auth (derived from code):** Roles: Sales User / Sales Manager / Stock Manager / System Manager\n\n**Permissions:** Counter roles (same as the fulfillment actions).\n\nSource: `apps/ffl_woo_sync/ffl_woo_sync/woocommerce/revenue.py:881`",
        "operationId": "ffl_woo_sync.woocommerce.revenue.create_web_invoice_now",
        "responses": {
          "200": {
            "description": "The booking result from create_sales_invoice_for_web_order.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "woo_online_order": {
                    "type": "string",
                    "description": "Woo Online Order name (must be Transferred)."
                  }
                },
                "required": [
                  "woo_online_order"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_woo_sync.woocommerce.tasks.alert_shipped_undisposed_orders": {
      "post": {
        "tags": [
          "ffl_woo_sync"
        ],
        "summary": "Report web orders WooCommerce says shipped while POS still holds them open.",
        "description": "A shipped firearm with no disposition is a missing A&D entry, and nothing\nsurfaced it before — the seven such orders on 2026-08-14 were found by hand.\n\nReports only; it never disposes anything. Which rifle went in the box is\nexactly what POS does not know in this state, and guessing it is the mistake\nthe whole serial-handling rework exists to stop.\n\n**Auth (derived from code):** Any authenticated user — no explicit role gate at function entry (deliberate open reads document this in Permissions).\n\n**Permissions:** Counter roles (manual path; the scheduler runs as Administrator).\n\nSource: `apps/ffl_woo_sync/ffl_woo_sync/woocommerce/tasks.py:1655`",
        "operationId": "ffl_woo_sync.woocommerce.tasks.alert_shipped_undisposed_orders",
        "responses": {
          "200": {
            "description": "{checked, reported} — `reported` is 0 when the daily throttle suppressed an otherwise non-empty report.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        }
      }
    },
    "/api/method/ffl_woo_sync.woocommerce.tasks.retry_stuck_serial_reservations": {
      "post": {
        "tags": [
          "ffl_woo_sync"
        ],
        "summary": "Re-apply the serial WooCommerce still holds to rows stuck on a STALE",
        "description": "``reservation_error``.\n\nA rejection is a snapshot of the moment it was written (\"that gun is held by\nWOO-ORD-x\"). The only thing that ever retried it was the next\n``order.updated`` webhook — so when the obstacle cleared (the other order\ncancelled, or swapped to a different gun) nothing re-ran, and a Woo order that\nhas gone ``completed`` sends no further webhook. The row then sat in the\nPending Order queue indefinitely, quoting a reason that had stopped being\ntrue, and staff had no way to clear it but to re-save the serial on Woo.\n(2026-08-07: WOO-ORD-01488 was refused C2322, which WOO-ORD-01491 released\neight minutes later; only an unrelated update two hours on unstuck it.)\n\nWhitelisted so staff can run it on demand rather than waiting out the cron —\nwhich also gives the aged-out orders below a manual way back in.\n\nBounded on every axis, because this is an unattended writer that calls an\nexternal store:\n\n* ``LIMIT`` per run, oldest first;\n* orders older than ``_RETRY_MAX_AGE_DAYS`` are reported **once** and then\n  left alone — a sweep that retries forever is how a permanent failure turns\n  into permanent noise (the lesson ``_fb_error_is_terminal`` encodes);\n* out-of-stock rejections are excluded outright: no dealer serial exists on\n  Woo to re-apply, so re-reading that order could never fix it;\n* per-site ``auto_sync_enabled`` gate, one Settings read per site.\n\n**Auth (derived from code):** Roles: Sales User / Sales Manager / Stock Manager / System Manager\n\n**Permissions:** Counter roles (manual path; the scheduler runs as Administrator).\n\nSource: `apps/ffl_woo_sync/ffl_woo_sync/woocommerce/tasks.py:1686`",
        "operationId": "ffl_woo_sync.woocommerce.tasks.retry_stuck_serial_reservations",
        "responses": {
          "200": {
            "description": "A summary dict (retried / cleared / aged-out / skipped counts) so a manual run says what it did.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        }
      }
    },
    "/api/method/ffl_woo_sync.woocommerce.variants.adopt_variable_product": {
      "post": {
        "tags": [
          "ffl_woo_sync"
        ],
        "summary": "Link a template to a variable product that already exists on the store, and",
        "description": "each variant to the variation whose SKU is its item code.\n\nAfterwards, pushing the template updates that product and those variations;\na variant with no variation there gets a new one, and a variation with no\nvariant is left as it is (``woo_only``).\n\n**Auth (derived from code):** Roles: System Manager\n\nSource: `apps/ffl_woo_sync/ffl_woo_sync/woocommerce/variants.py:112`",
        "operationId": "ffl_woo_sync.woocommerce.variants.adopt_variable_product",
        "responses": {
          "200": {
            "description": "{ok, dry_run, template, product, matched, pos_only, woo_only, replaced}: ``matched`` is {item_code: variation id}; ``replaced`` the product ids the Items held before.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "template": {
                    "type": "string",
                    "description": "The template Item."
                  },
                  "woo_product_id": {
                    "description": "The variable product's id on the store."
                  },
                  "site": {
                    "type": "string",
                    "description": "\"retail\" (default; the only store).",
                    "default": "retail"
                  },
                  "dry_run": {
                    "description": "1 (default) only reads the store and reports; 0 writes the ids.",
                    "default": 1
                  }
                },
                "required": [
                  "template",
                  "woo_product_id"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_woo_sync.woocommerce.variants.make_variants": {
      "post": {
        "tags": [
          "ffl_woo_sync"
        ],
        "summary": "Make existing Items variants of a template, keeping their item codes.",
        "description": "Sets each Item's ``variant_of`` and its attribute values. Nothing is written\nwhen any Item fails a check (unknown Item, already another template's variant,\nmissing or unknown attribute value, the same values as another requested Item\nor an existing variant).\n\nAn Item that is listed as its own simple product loses that link\n(``{site}_product_id`` / ``listed`` cleared, returned in ``cleared``): as a\nvariant its id must be a variation of the template's product, so a stale\nsimple-product id would be sent as a variation id. The simple product itself\nis left on the store — draft or trash it there, or link the variant to its\nvariation with :func:`adopt_variable_product`.\n\n**Auth (derived from code):** Roles: System Manager\n\nSource: `apps/ffl_woo_sync/ffl_woo_sync/woocommerce/variants.py:68`",
        "operationId": "ffl_woo_sync.woocommerce.variants.make_variants",
        "responses": {
          "200": {
            "description": "{ok, dry_run, template, errors, variants, cleared}: ``variants`` is the item codes that are (or would be) variants of the template; ``cleared`` is {item_code: the simple product id it held} for Items that were not yet variants.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "template": {
                    "type": "string",
                    "description": "The template Item (Has Variants on, with its attributes)."
                  },
                  "variants": {
                    "description": "``{item_code: {attribute: value}}`` (a dict or its JSON)."
                  },
                  "dry_run": {
                    "description": "1 (default) only checks; 0 writes.",
                    "default": 1
                  }
                },
                "required": [
                  "template",
                  "variants"
                ]
              }
            }
          }
        }
      }
    },
    "/api/method/ffl_woo_sync.woocommerce.webhook.woo_event": {
      "post": {
        "tags": [
          "webhooks"
        ],
        "summary": "Single WooCommerce webhook entry point (guest, HMAC-verified).",
        "description": "**Auth (derived from code):** Guest — no session; the endpoint verifies the caller itself (HMAC signature, HTTP Basic credentials or a one-time token).\n\n**Payload:** WooCommerce's webhook JSON body; the X-WC-Webhook-Topic header selects the handler (order.created/updated, product.*, ...). The X-WC-Webhook-Signature header must carry a valid HMAC over the raw body (secret configured in Woo Sync Settings).\n\nSource: `apps/ffl_woo_sync/ffl_woo_sync/woocommerce/webhook.py:3089`",
        "operationId": "ffl_woo_sync.woocommerce.webhook.woo_event",
        "responses": {
          "200": {
            "description": "200 with a minimal JSON body ({ok, topic/handled/error}) on success. 400 when ``?site=`` names a store this POS does not run (only the retail store is connected) and 401 when HMAC verification fails — the two cases that mean \"stop delivering here\", which is what a 4xx gets WooCommerce to do; the order is not read or processed for either. Every other outcome logs (where there is anything worth logging) and returns 200, so WooCommerce does not retry or auto-disable the webhook over something the caller cannot fix.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/FrappeError"
          }
        },
        "security": []
      }
    }
  }
}
