Skip to content

design: define order void and archive semantics #703

Open

Description

@itsbkm

Problem

Hard deletion of orders can bypass inventory reversal, financial history, and audit requirements. PR #304 therefore cannot be merged safely.

Design questions

  • Define when an order may be voided and who may perform the action.
  • Preserve an immutable audit event with actor, reason, and timestamp.
  • Define inventory reversal behavior for sent, fulfilled, paid, and partially paid orders.
  • Define reporting and receipt visibility for voided and archived orders.
  • Prefer archive or status transitions over destructive deletion.

Scope boundary

Receipt changes from PR #304 are excluded. Re-propose them independently with their own acceptance criteria if still needed.

Exit criteria

A reviewed design specifies lifecycle states, permissions, inventory effects, payment effects, reporting behavior, and upgrade compatibility before implementation starts.

Activity

  1. added
    area:backend
    priority:high
    type:design
    state:needs-design
    on Nov 28, 2026
  2. khaira777 commented on Nov 28, 2026

    @khaira777
    Contributor

    Codebase anchor & alignment update (origin/main @ 3cef9027):

    Current implementation anchors:

    • Item-level void / cancel / restore: main/routes/order-items.ts:259-362,449-489 (voided, void_adjustment, cancelled, voided_at KDS visibility) and main/routes/orders.ts (order cancel, item edit).
    • Inventory & recipe waste invariant (docs/reference/product-invariants.md:402-406): cancelling pending lines restores product stock & recipe_snapshot supplies; voiding started (preparing/ready/served/completed) lines treats depletion as physical waste and does not restore stock.
    • Post-payment reversals: main/services/refund.ts & main/routes/refunds.ts (Staff Approval PIN tiers, refund_issued written to order_audit_log via main/db.ts:11688).
    • Reports filter: main/routes/reports.ts:847 excludes ('cancelled', 'voided', 'void_adjustment', 'refunded').

    Cross-issue alignment:

    • Distinct from #1450 (pre-go-live full transactional test-data purge with backup).
    • Directly informs #287 (append-only audit event taxonomy) and Phase 4 tombstones in the upcoming Open Integration Platform RFC.
    • Design decisions to lock: (1) exact allowed state transitions for whole-order void (unpaid vs partially_paid vs paid), (2) required permission + Staff Approval PIN threshold for order void/archive, (3) archived_at soft-archive visibility in Orders, Search FTS (orders_search_fts), and Z-reports/Daily Sales exports.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:backendpriority:highstate:needs-designtype:design

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions