Skip to content

feat(mcp): default create_purchase_order to DRAFT status#878

Open
dougborg wants to merge 2 commits into
mainfrom
feat/po-create-default-draft
Open

feat(mcp): default create_purchase_order to DRAFT status#878
dougborg wants to merge 2 commits into
mainfrom
feat/po-create-default-draft

Conversation

@dougborg
Copy link
Copy Markdown
Owner

Summary

create_purchase_order now creates new POs in DRAFT by default instead of
NOT_RECEIVED. An API-created PO that a human hasn't approved is conceptually an
unsent draft — the operator can review and edit it before committing the order to
the supplier. The previous default forced a manual "send back to draft" fixup in
the Katana UI on every programmatically created PO (5–6 per StockTrim split).

DRAFT support itself already shipped in client v0.50.0 (Apr 9); this PR only
flips the default and clarifies the docs.

Changes

  • Flip the status field default None (→ Katana's NOT_RECEIVED) → "DRAFT",
    and send DRAFT explicitly on the apply path rather than leaving it UNSET.
  • Preview card reflects DRAFT so the operator sees the target state.
  • Expand the status field description, tool docstring, and katana://help
    entry to enumerate DRAFT vs NOT_RECEIVED, how to opt out
    (status="NOT_RECEIVED" for already-placed orders), and how to transition
    later (modify_purchase_order / receive_purchase_order).
  • Regression tests: DRAFT default on apply + preview, and explicit
    NOT_RECEIVED still forwards unchanged.

Opt-out

Callers wanting an already-ordered PO pass status="NOT_RECEIVED" explicitly.

Test plan

  • uv run poe check — 3783 passed, 8 skipped + 42 browser tests passed
  • New regression tests pin DRAFT default (apply + preview) and explicit
    NOT_RECEIVED forwarding
  • Verified live MCP inputSchema advertises "default": "DRAFT" with the
    ["DRAFT", "NOT_RECEIVED"] enum end-to-end
  • Reviewer: confirm the DRAFT default is the desired cross-cutting behavior
    (affects all PO creation lacking an explicit status — StockTrim split,
    correct_purchase_order, etc.)

Note: requires a katana-erp-dev redeploy to reach the live server.

🤖 Generated with Claude Code

Copilot AI review requested due to automatic review settings May 29, 2026 23:03
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the MCP create_purchase_order tool so that newly created purchase orders default to DRAFT (instead of relying on Katana’s API default of NOT_RECEIVED), aligning programmatic PO creation with an “operator-review-first” workflow.

Changes:

  • Set CreatePurchaseOrderRequest.status default to "DRAFT" and ensure the apply path sends DRAFT explicitly when unspecified.
  • Update preview responses and tool/docs text to reflect the new default and explain how to opt out (status="NOT_RECEIVED").
  • Add regression tests covering (a) default-to-DRAFT behavior and (b) explicit NOT_RECEIVED forwarding.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
katana_mcp_server/src/katana_mcp/tools/foundation/purchase_orders.py Changes the request default, apply-path API payload behavior, preview card status, and expands status documentation.
katana_mcp_server/tests/tools/test_purchase_orders.py Adds regression tests asserting the new default behavior and explicit override behavior.
katana_mcp_server/src/katana_mcp/resources/help.py Updates katana://help documentation to reflect DRAFT as the default and clarify semantics.

Comment thread katana_mcp_server/src/katana_mcp/tools/foundation/purchase_orders.py Outdated
New POs created via create_purchase_order now land in DRAFT — an unsent
draft the operator can review and edit before committing the order to the
supplier — instead of NOT_RECEIVED. An API-created PO that a human hasn't
approved is conceptually a draft, not an already-placed order; the previous
default forced a manual "send back to draft" fixup in the Katana UI on every
programmatically created PO.

- Flip the `status` field default from None (→ Katana's NOT_RECEIVED) to
  "DRAFT", and send DRAFT explicitly on the apply path rather than leaving
  it UNSET.
- Reflect DRAFT on the preview card so the operator sees the target state.
- Expand the `status` field + tool docstring + katana://help entry to
  enumerate DRAFT vs NOT_RECEIVED, how to opt out (status="NOT_RECEIVED"
  for already-placed orders), and how to transition later
  (modify_purchase_order / receive_purchase_order).
- Add regression tests pinning the DRAFT default (apply + preview) and that
  an explicit NOT_RECEIVED still forwards unchanged.

Callers wanting an already-ordered PO pass status="NOT_RECEIVED" explicitly.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@dougborg dougborg force-pushed the feat/po-create-default-draft branch from c0b13b0 to 2b47492 Compare May 29, 2026 23:22
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated no new comments.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants